Datagrid Template columns shows data from first row

Discussion in 'ASP .Net' started by Guest, Jul 7, 2003.

  1. Guest

    Guest Guest

    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, Jul 7, 2003
    #1
    1. Advertising

  2. 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: <>
    >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: <>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >NNTP-Posting-Host: 12.108.131.130
    >Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.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], Jul 8, 2003
    #2
    1. Advertising

  3. Guest

    Guest Guest

    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]" <> wrote in message
    news:...
    > 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: <>
    > >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: <>
    > >Newsgroups: microsoft.public.dotnet.framework.aspnet
    > >NNTP-Posting-Host: 12.108.131.130
    > >Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.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, Jul 8, 2003
    #3
  4. Guest

    Guest Guest

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

    --
    Barry Fitzgerald


    <> wrote in message
    news:...
    > 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]" <> wrote in message
    > news:...
    > > 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: <>
    > > >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: <>
    > > >Newsgroups: microsoft.public.dotnet.framework.aspnet
    > > >NNTP-Posting-Host: 12.108.131.130
    > > >Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.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, Jul 8, 2003
    #4
  5. 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
    http://msdn.microsoft.com/library/en-us/cpgenref/html/cpcondatabindingexpres
    sionsyntax.asp

    Regards,

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


    --------------------
    >From: <>
    >References: <>

    <>
    <>
    >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: <>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >NNTP-Posting-Host: exchange.gumdropbooks.com 12.108.131.130
    >Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.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
    >
    >
    ><> wrote in message
    >news:...
    >> 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]" <> wrote in message
    >> news:...
    >> > 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: <>
    >> > >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: <>
    >> > >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >> > >NNTP-Posting-Host: 12.108.131.130
    >> > >Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.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], Jul 9, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gce
    Replies:
    0
    Views:
    776
  2. D
    Replies:
    0
    Views:
    229
  3. b301
    Replies:
    0
    Views:
    1,213
  4. Vinki

    template columns and bound columns in gridview

    Vinki, Apr 25, 2007, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    885
    Vinki
    Apr 25, 2007
  5. Gianni

    IE shows false and Firefox shows true

    Gianni, Jul 10, 2009, in forum: Javascript
    Replies:
    3
    Views:
    471
    Thomas 'PointedEars' Lahn
    Jul 10, 2009
Loading...

Share This Page