473,748 Members | 8,530 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Nov 17 '05 #1
4 5403
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.Autho r") %>'>
...
</ItemTemplate>

Regards,

Felix Wu
=============
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: <Ba*****@home.c om>
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: <eB************ **@TK2MSFTNGP12 .phx.gbl>
Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
NNTP-Posting-Host: 12.108.131.130
Path: cpmsftngxa09.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP12.phx.g bl
Xref: cpmsftngxa09.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:3267 0
X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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 columnsshowing 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


Nov 17 '05 #2
I work in the IDE and this is the code generated by the template editor:

<asp:TemplateCo lumn HeaderText="Tit le">
<ItemTemplate >
<asp:HyperLin k id=HyperLink1 runat="server" Text='<%#
DataBinder.Eval (dsBookSearch, "Tables[BookSearch].DefaultView.[0].Title")
%>' navigateUrl="Bo okInfo.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:TemplateCol umn>
--
Barry Fitzgerald
"Felix Wu [MSFT]" <fe*****@online .microsoft.com> wrote in message
news:Uw******** ******@cpmsftng xa09.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.Autho r") %>'>
...
</ItemTemplate>

Regards,

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

--------------------
From: <Ba*****@home.c om>
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: <eB************ **@TK2MSFTNGP12 .phx.gbl>
Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
NNTP-Posting-Host: 12.108.131.130
Path: cpmsftngxa09.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP12.phx.g bl
Xref: cpmsftngxa09.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:3267 0
X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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 isbound 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 othernone template columns are fine. Obviously I am not understanding somethinghere. What am I missing?????

--
Barry Fitzgerald

Nov 17 '05 #3
I got it to work by using Container,DataI tem... I don't understand why
this works but refrencing the dataset does not?

--
Barry Fitzgerald
<Ba*****@home.c om> wrote in message
news:Oc******** ******@TK2MSFTN GP10.phx.gbl...
I work in the IDE and this is the code generated by the template editor:

<asp:TemplateCo lumn HeaderText="Tit le">
<ItemTemplate >
<asp:HyperLin k id=HyperLink1 runat="server" Text='<%#
DataBinder.Eval (dsBookSearch, "Tables[BookSearch].DefaultView.[0].Title")
%>' navigateUrl="Bo okInfo.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:TemplateCol umn>
--
Barry Fitzgerald
"Felix Wu [MSFT]" <fe*****@online .microsoft.com> wrote in message
news:Uw******** ******@cpmsftng xa09.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.Autho r") %>'>
...
</ItemTemplate>

Regards,

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

rights.


--------------------
From: <Ba*****@home.c om>
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: <eB************ **@TK2MSFTNGP12 .phx.gbl>
Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
NNTP-Posting-Host: 12.108.131.130
Path: cpmsftngxa09.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP12.phx.g bl
Xref: cpmsftngxa09.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:3267 0X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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 isbound 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 othernone template columns are fine. Obviously I am not understanding somethinghere. What am I missing?????

--
Barry Fitzgerald


Nov 17 '05 #4
Hi Barry,

ASP.NET provides you many binding options for different purpose.
Container.DataI tem 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: <Ba*****@home.c om>
References: <eB************ **@TK2MSFTNGP12 .phx.gbl> <Uw************ **@cpmsftngxa09 .phx.gbl>
<Oc************ **@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: <eL************ **@tk2msftngp13 .phx.gbl>
Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
NNTP-Posting-Host: exchange.gumdro pbooks.com 12.108.131.130
Path: cpmsftngxa09.ph x.gbl!TK2MSFTNG P08.phx.gbl!tk2 msftngp13.phx.g bl
Xref: cpmsftngxa09.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:3295 9
X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet

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

--
Barry Fitzgerald
<Ba*****@home. com> wrote in message
news:Oc******* *******@TK2MSFT NGP10.phx.gbl.. .
I work in the IDE and this is the code generated by the template editor:

<asp:TemplateCo lumn HeaderText="Tit le">
<ItemTemplate >
<asp:HyperLin k id=HyperLink1 runat="server" Text='<%#
DataBinder.Eval (dsBookSearch, "Tables[BookSearch].DefaultView.[0].Title")
%>' navigateUrl="Bo okInfo.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:TemplateCol umn>
--
Barry Fitzgerald
"Felix Wu [MSFT]" <fe*****@online .microsoft.com> wrote in message
news:Uw******** ******@cpmsftng xa09.phx.gbl...
> HI Barry,
>
> How did you bind the data? Check the HTML view of the page, how doesbind > line look like?
>
> Please try this:
>
> <ItemTemplate >
> <asp:Label id="Label1" runat="server" Text='<%#

DataBinder.Eval (Container,
> "DataItem.Autho r") %>'>
> ...
> </ItemTemplate>
>
> Regards,
>
> Felix Wu
> =============
> This posting is provided "AS IS" with no warranties, and confers no

rights.
>
>
> --------------------
> >From: <Ba*****@home.c om>
> >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: <eB************ **@TK2MSFTNGP12 .phx.gbl>
> >Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
> >NNTP-Posting-Host: 12.108.131.130
> >Path: cpmsftngxa09.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP12.phx.g bl
> >Xref: cpmsftngxa09.ph x.gblmicrosoft.publ ic.dotnet.frame work.aspnet:326 70 > >X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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
> >
> >
> >
> >
>




Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4880
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that the best method? Do you have a sample of how to do this?
2
2260
by: enak | last post by:
I can not get my datagrid to page. I have a datagrid that I can sort 2 of the columns. This works great. I added paging and when I display the dg it shows 5 pages. (I am showing page numbers at the bottom of the dg.) When I click on the pages nothing happens until I get to the last page. Then and only then is the last page displayed. If I go back through the pages the second to last page displayes the first page again.
4
2176
by: Chris | last post by:
I've searched, reviewed, and attempted dozens of code ideas on the subject. I can't seem to get something that seems so simple to work. To highlight a row in a datagrid based on another value in that row. I have a datagrid using Template and Item Columns, i.e.: <asp:TemplateColumn HeaderText="CA Date Req" HeaderStyle-CssClass="gridqtext" ItemStyle-CssClass="gridtext"> <ItemTemplate> <asp:Label ID="lblcadatereq" CssClass="gridtext"...
6
1840
by: Khumar | last post by:
Hello, Im new in asp.net especially in web base application. I want to ask about datagrid. I had shown my table on datagrid, and what I want to ask is how to set the column height fixed? Because when I have a long word it automatically set new line instead of hide it. I want it to be hide like this 928192... with 3 dot at the end of the word if it is to long.
1
1677
by: headbig003 | last post by:
Hello I put template column in datagrid. Below is the html code I used. <asp:datagrid id="dgAnswer" runat="server" Width="360px" AutoGenerateColumns="False" DataKeyField="ansID"> <Columns> <asp:TemplateColumn HeaderText="Answer Text"> <ItemTemplate> <asp:TextBox id="txtItem" runat="server" Width="201px" Text='<%#
5
2654
by: Gary Blakely | last post by:
I'm giving this post another try - it can't be too difficult for everyone.... In the program below, the web page has dataGrid1. the only thing that has been done to it at design time is to check the "Create columns automatically at runtime" checkbox - nothing else. The code below does indeed create the visual grid as expected. Furthermore the Cell contents and Item count all exist and contain expected values. However there is no...
1
1094
by: serge calderara | last post by:
Dear all, When I place a datagrid server control on a webform by default it shows 3 columns My application makes runtime data binding to a table in database. So far it works well all my column present on my bind dataset gets displayed properly. Then I try to use template on Column 0 abut when I run my application again, the fact of adding a template to column 0 has add an extra column before the column 0..
6
5745
by: p.mc | last post by:
Hi all, I'm having major problems with a userControl which contains a datagrid. My problem concerns data binding. The Page_Load() procedure calls the DataBind procedure to bind the datagrid to a DataSet. If i include an if statement to prevent the data binding from occuring on a page PostBack in the following way:
8
3895
by: Matt | last post by:
Guys I could really use some help with this. I think that it's probably a simple solution but I haven't been able to find anything. I have a datagrid on my form that I populate via code like this... Me.My_DataGrid.Rows.Add(Column1, Column2, Column3) Well now I have a datagrid that I want to populate with an image. So for example...
0
8828
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9537
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9243
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.