Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Datagrid Template columns shows data from first row

Reply
Thread Tools

Datagrid Template columns shows data from first row

 
 
Guest
Posts: n/a
 
      07-07-2003
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



 
Reply With Quote
 
 
 
 
Felix Wu [MSFT]
Guest
Posts: n/a
 
      07-08-2003
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: <(E-Mail Removed)>
>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: <(E-Mail Removed)>
>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
>
>
>
>


 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      07-08-2003
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]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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: <(E-Mail Removed)>
> >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: <(E-Mail Removed)>
> >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
> >
> >
> >
> >

>



 
Reply With Quote
 
Guest
Posts: n/a
 
      07-08-2003
I got it to work by using Container,DataItem... I don't understand why
this works but refrencing the dataset does not?

--
Barry Fitzgerald


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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: <(E-Mail Removed)>
> > >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: <(E-Mail Removed)>
> > >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
> > >
> > >
> > >
> > >

> >

>
>



 
Reply With Quote
 
Felix Wu [MSFT]
Guest
Posts: n/a
 
      07-09-2003
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...abindingexpres
sionsyntax.asp

Regards,

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


--------------------
>From: <(E-Mail Removed)>
>References: <(E-Mail Removed)>

<(E-Mail Removed)>
<(E-Mail Removed)>
>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: <(E-Mail Removed)>
>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
>
>
><(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>> 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]" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > 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: <(E-Mail Removed)>
>> > >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: <(E-Mail Removed)>
>> > >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
>> > >
>> > >
>> > >
>> > >
>> >

>>
>>

>
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
template columns and bound columns in gridview Vinki ASP .Net Web Controls 2 04-25-2007 04:22 PM
ok I can do a totals row but how about a percentage row after each data row D ASP .Net Datagrid Control 0 05-23-2005 04:10 PM
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. Daniel Roth ASP .Net Datagrid Control 0 04-05-2005 03:58 AM
binding data to datagrid(template columns) Daniel Caetano ASP .Net Datagrid Control 0 02-27-2004 08:00 PM
Columns and Inherited Datagrid...Active Schema does not support columns rob thomson ASP .Net Datagrid Control 0 09-04-2003 03:09 PM



Advertisments