Datagrid Template columns shows data from first row

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Datagrid Template columns shows data from first row

    I have a datagrid with a template column that has a hyperlink and a label.
    The hyperlink text is bound to Title from my dataset and the label text is
    bound to Author in the dataset. The grid displays with the template columns
    showing the Title and the Author from the first row in all rows. The other
    none template columns are fine. Obviously I am not understanding something
    here. What am I missing?????

    --
    Barry Fitzgerald



    Guest

  2. Similar Questions and Discussions

    1. How to add a Dropdown list to a datagrid at runtime (dynamic) without using template columns in ASP.NET and still have the ability to us the datagrid Update event.
      How to add a Dropdown list to a datagrid at runtime (dynamic) without using template columns in ASP.NET and still have the ability to us the...
    2. recover value from datagrid w/template columns
      Hi, a time before i have asked about how to recover a sigle field value when editing a row in a datagrid. you answer me that i can use the datakey...
    3. binding data to datagrid(template columns)
      I create a datagrid where only have 2 template columns(label control) . I want to populate them from a dataset , but i donīt know how to do it??...
    4. Dynamic datagrid template Columns Need Help.
      I am having problems trying to create these template columns dynamically. '<Columns> ' <asp:TemplateColumn> ' <ItemTemplate> ' <asp:LinkButton...
    5. ClintID does not work for datagrid template columns controls
      Hello I have a datagrid "dg" which has two template columns. The first template column contains a button denoted "b" and the second template column...
  3. #2

    Default RE: Datagrid Template columns shows data from first row

    HI Barry,

    How did you bind the data? Check the HTML view of the page, how does bind
    line look like?

    Please try this:

    <ItemTemplate>
    <asp:Label id="Label1" runat="server" Text='<%# DataBinder.Eval(Container,
    "DataItem.Author") %>'>
    ...
    </ItemTemplate>

    Regards,

    Felix Wu
    =============
    This posting is provided "AS IS" with no warranties, and confers no rights.


    --------------------
    >From: <BarryFz@home.com>
    >Subject: Datagrid Template columns shows data from first row
    >Date: Mon, 7 Jul 2003 07:36:56 -0500
    >Lines: 12
    >X-Priority: 3
    >X-MSMail-Priority: Normal
    >X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
    >Message-ID: <eBAUtRIRDHA.2204@TK2MSFTNGP12.phx.gbl>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >NNTP-Posting-Host: 12.108.131.130
    >Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
    >Xref: cpmsftngxa09.phx.gbl microsoft.public.dotnet.framework.aspnet:32670
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    >
    >I have a datagrid with a template column that has a hyperlink and a label.
    >The hyperlink text is bound to Title from my dataset and the label text is
    >bound to Author in the dataset. The grid displays with the template
    columns
    >showing the Title and the Author from the first row in all rows. The other
    >none template columns are fine. Obviously I am not understanding something
    >here. What am I missing?????
    >
    >--
    >Barry Fitzgerald
    >
    >
    >
    >
    Felix Wu [MSFT] Guest

  4. #3

    Default Re: Datagrid Template columns shows data from first row

    I work in the IDE and this is the code generated by the template editor:

    <asp:TemplateColumn HeaderText="Title">
    <ItemTemplate>
    <asp:HyperLink id=HyperLink1 runat="server" Text='<%#
    DataBinder.Eval(dsBookSearch, "Tables[BookSearch].DefaultView.[0].Title")
    %>' navigateUrl="BookInfo.aspx">
    </asp:HyperLink><BR>
    <asp:Label id="Label2" runat="server"> by </asp:Label>&nbsp;
    <asp:Label id=Label1 runat="server" Text='<%#
    DataBinder.Eval(dsBookSearch, "Tables[BookSearch].DefaultView.[0].Author")
    %>'>
    </asp:Label>
    </ItemTemplate>
    </asp:TemplateColumn>
    --
    Barry Fitzgerald


    "Felix Wu [MSFT]" <felixwu@online.microsoft.com> wrote in message
    news:UwcpA4PRDHA.1748@cpmsftngxa09.phx.gbl...
    > HI Barry,
    >
    > How did you bind the data? Check the HTML view of the page, how does bind
    > line look like?
    >
    > Please try this:
    >
    > <ItemTemplate>
    > <asp:Label id="Label1" runat="server" Text='<%#
    DataBinder.Eval(Container,
    > "DataItem.Author") %>'>
    > ...
    > </ItemTemplate>
    >
    > Regards,
    >
    > Felix Wu
    > =============
    > This posting is provided "AS IS" with no warranties, and confers no
    rights.
    >
    >
    > --------------------
    > >From: <BarryFz@home.com>
    > >Subject: Datagrid Template columns shows data from first row
    > >Date: Mon, 7 Jul 2003 07:36:56 -0500
    > >Lines: 12
    > >X-Priority: 3
    > >X-MSMail-Priority: Normal
    > >X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
    > >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
    > >Message-ID: <eBAUtRIRDHA.2204@TK2MSFTNGP12.phx.gbl>
    > >Newsgroups: microsoft.public.dotnet.framework.aspnet
    > >NNTP-Posting-Host: 12.108.131.130
    > >Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
    > >Xref: cpmsftngxa09.phx.gbl microsoft.public.dotnet.framework.aspnet:32670
    > >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    > >
    > >I have a datagrid with a template column that has a hyperlink and a
    label.
    > >The hyperlink text is bound to Title from my dataset and the label text
    is
    > >bound to Author in the dataset. The grid displays with the template
    > columns
    > >showing the Title and the Author from the first row in all rows. The
    other
    > >none template columns are fine. Obviously I am not understanding
    something
    > >here. What am I missing?????
    > >
    > >--
    > >Barry Fitzgerald
    > >
    > >
    > >
    > >
    >

    Guest

  5. #4

    Default Re: Datagrid Template columns shows data from first row

    I got it to work by using Container,DataItem... I don't understand why
    this works but refrencing the dataset does not?

    --
    Barry Fitzgerald


    <BarryFz@home.com> wrote in message
    news:OceNkOURDHA.2676@TK2MSFTNGP10.phx.gbl...
    > I work in the IDE and this is the code generated by the template editor:
    >
    > <asp:TemplateColumn HeaderText="Title">
    > <ItemTemplate>
    > <asp:HyperLink id=HyperLink1 runat="server" Text='<%#
    > DataBinder.Eval(dsBookSearch, "Tables[BookSearch].DefaultView.[0].Title")
    > %>' navigateUrl="BookInfo.aspx">
    > </asp:HyperLink><BR>
    > <asp:Label id="Label2" runat="server"> by </asp:Label>&nbsp;
    > <asp:Label id=Label1 runat="server" Text='<%#
    > DataBinder.Eval(dsBookSearch, "Tables[BookSearch].DefaultView.[0].Author")
    > %>'>
    > </asp:Label>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > --
    > Barry Fitzgerald
    >
    >
    > "Felix Wu [MSFT]" <felixwu@online.microsoft.com> wrote in message
    > news:UwcpA4PRDHA.1748@cpmsftngxa09.phx.gbl...
    > > HI Barry,
    > >
    > > How did you bind the data? Check the HTML view of the page, how does
    bind
    > > line look like?
    > >
    > > Please try this:
    > >
    > > <ItemTemplate>
    > > <asp:Label id="Label1" runat="server" Text='<%#
    > DataBinder.Eval(Container,
    > > "DataItem.Author") %>'>
    > > ...
    > > </ItemTemplate>
    > >
    > > Regards,
    > >
    > > Felix Wu
    > > =============
    > > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    > >
    > >
    > > --------------------
    > > >From: <BarryFz@home.com>
    > > >Subject: Datagrid Template columns shows data from first row
    > > >Date: Mon, 7 Jul 2003 07:36:56 -0500
    > > >Lines: 12
    > > >X-Priority: 3
    > > >X-MSMail-Priority: Normal
    > > >X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
    > > >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
    > > >Message-ID: <eBAUtRIRDHA.2204@TK2MSFTNGP12.phx.gbl>
    > > >Newsgroups: microsoft.public.dotnet.framework.aspnet
    > > >NNTP-Posting-Host: 12.108.131.130
    > > >Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
    > > >Xref: cpmsftngxa09.phx.gbl
    microsoft.public.dotnet.framework.aspnet:32670
    > > >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    > > >
    > > >I have a datagrid with a template column that has a hyperlink and a
    > label.
    > > >The hyperlink text is bound to Title from my dataset and the label text
    > is
    > > >bound to Author in the dataset. The grid displays with the template
    > > columns
    > > >showing the Title and the Author from the first row in all rows. The
    > other
    > > >none template columns are fine. Obviously I am not understanding
    > something
    > > >here. What am I missing?????
    > > >
    > > >--
    > > >Barry Fitzgerald
    > > >
    > > >
    > > >
    > > >
    > >
    >
    >

    Guest

  6. #5

    Default Re: Datagrid Template columns shows data from first row

    Hi Barry,

    ASP.NET provides you many binding options for different purpose.
    Container.DataItem allows you to bind to each element of DataSource. For
    more information about Data Binding, the following link may help:

    Data Binding Expression Syntax
    [url]http://msdn.microsoft.com/library/en-us/cpgenref/html/cpcondatabindingexpres[/url]
    sionsyntax.asp

    Regards,

    Felix Wu
    =============
    This posting is provided "AS IS" with no warranties, and confers no rights.


    --------------------
    >From: <BarryFz@home.com>
    >References: <eBAUtRIRDHA.2204@TK2MSFTNGP12.phx.gbl>
    <UwcpA4PRDHA.1748@cpmsftngxa09.phx.gbl>
    <OceNkOURDHA.2676@TK2MSFTNGP10.phx.gbl>
    >Subject: Re: Datagrid Template columns shows data from first row
    >Date: Tue, 8 Jul 2003 07:06:47 -0500
    >Lines: 93
    >X-Priority: 3
    >X-MSMail-Priority: Normal
    >X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
    >Message-ID: <eLpLhlURDHA.3796@tk2msftngp13.phx.gbl>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >NNTP-Posting-Host: exchange.gumdropbooks.com 12.108.131.130
    >Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
    >Xref: cpmsftngxa09.phx.gbl microsoft.public.dotnet.framework.aspnet:32959
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    >
    >I got it to work by using Container,DataItem... I don't understand why
    >this works but refrencing the dataset does not?
    >
    >--
    >Barry Fitzgerald
    >
    >
    ><BarryFz@home.com> wrote in message
    >news:OceNkOURDHA.2676@TK2MSFTNGP10.phx.gbl...
    >> I work in the IDE and this is the code generated by the template editor:
    >>
    >> <asp:TemplateColumn HeaderText="Title">
    >> <ItemTemplate>
    >> <asp:HyperLink id=HyperLink1 runat="server" Text='<%#
    >> DataBinder.Eval(dsBookSearch, "Tables[BookSearch].DefaultView.[0].Title")
    >> %>' navigateUrl="BookInfo.aspx">
    >> </asp:HyperLink><BR>
    >> <asp:Label id="Label2" runat="server"> by </asp:Label>&nbsp;
    >> <asp:Label id=Label1 runat="server" Text='<%#
    >> DataBinder.Eval(dsBookSearch,
    "Tables[BookSearch].DefaultView.[0].Author")
    >> %>'>
    >> </asp:Label>
    >> </ItemTemplate>
    >> </asp:TemplateColumn>
    >> --
    >> Barry Fitzgerald
    >>
    >>
    >> "Felix Wu [MSFT]" <felixwu@online.microsoft.com> wrote in message
    >> news:UwcpA4PRDHA.1748@cpmsftngxa09.phx.gbl...
    >> > HI Barry,
    >> >
    >> > How did you bind the data? Check the HTML view of the page, how does
    >bind
    >> > line look like?
    >> >
    >> > Please try this:
    >> >
    >> > <ItemTemplate>
    >> > <asp:Label id="Label1" runat="server" Text='<%#
    >> DataBinder.Eval(Container,
    >> > "DataItem.Author") %>'>
    >> > ...
    >> > </ItemTemplate>
    >> >
    >> > Regards,
    >> >
    >> > Felix Wu
    >> > =============
    >> > This posting is provided "AS IS" with no warranties, and confers no
    >> rights.
    >> >
    >> >
    >> > --------------------
    >> > >From: <BarryFz@home.com>
    >> > >Subject: Datagrid Template columns shows data from first row
    >> > >Date: Mon, 7 Jul 2003 07:36:56 -0500
    >> > >Lines: 12
    >> > >X-Priority: 3
    >> > >X-MSMail-Priority: Normal
    >> > >X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
    >> > >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
    >> > >Message-ID: <eBAUtRIRDHA.2204@TK2MSFTNGP12.phx.gbl>
    >> > >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >> > >NNTP-Posting-Host: 12.108.131.130
    >> > >Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
    >> > >Xref: cpmsftngxa09.phx.gbl
    >microsoft.public.dotnet.framework.aspnet:32670
    >> > >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    >> > >
    >> > >I have a datagrid with a template column that has a hyperlink and a
    >> label.
    >> > >The hyperlink text is bound to Title from my dataset and the label
    text
    >> is
    >> > >bound to Author in the dataset. The grid displays with the template
    >> > columns
    >> > >showing the Title and the Author from the first row in all rows. The
    >> other
    >> > >none template columns are fine. Obviously I am not understanding
    >> something
    >> > >here. What am I missing?????
    >> > >
    >> > >--
    >> > >Barry Fitzgerald
    >> > >
    >> > >
    >> > >
    >> > >
    >> >
    >>
    >>
    >
    >
    >
    Felix Wu [MSFT] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139