Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Using databound values in a Datagrids Template column


Message #1 by "Nick Charlesworth" <nick@f...> on Fri, 30 Aug 2002 10:06:44
You need to put a # after the % and you don't need the equal sign.  The 
DataBinder.Eval object may be a little heavy handed for what you are 
doing here.  You can get away with <%# Container.DataItem("strTitle")%>. 
 The DataBinder.Eval object allows you to format values like numbers and 
dates.

Hope this helps,
David
-----Original Message-----
From: Nick Charlesworth [mailto:nick@f...]
Sent: Friday, August 30, 2002 6:07 AM
To: ASPX_Professional
Subject: [aspx_professional] Using databound values in a Datagrids 
Template column

Hi,

I am wanting to use a Template column in a datagrid control and have the 

following code:

<asp:DataGrid id=3D"dgSearchResults" runat=3D"server" PageSize=3D"10"
AllowPaging=3D"True" cellpadding=3D"4" cellspacing=3D"1"
autogeneratecolumns=3D"false">
		<PagerStyle Mode=3D"NumericPages" Position=3D"Bottom"
HorizontalAlign=3D"Center" ForeColor=3D"White"
BackColor=3D"#27547e"></PagerStyle>
		<Columns>
<asp:BoundColumn DataField=3D"MessageID" visible=3D"False" />
<asp:TemplateColumn HeaderText=3D"Template column">
  <ItemTemplate>
    <a href=3D"thread.aspx?MessageID=3D"><%=3D DataBinder.Eval
(Container.DataItem, "strTitle") %></a>
  </ItemTemplate>
</asp:TemplateColumn>

It is returning the error:

Name 'Container' is not declared.

I have based the code on an article on 4guysfromrolla.com

Has anyone had similar problems or know what the problem is?

thanks,

Nick


		=09
</Columns>
</asp:DataGrid>
---

ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=3D1861007442

ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=3D1861007450

These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples. 

---

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.381 / Virus Database: 214 - Release Date: 8/2/2002


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.381 / Virus Database: 214 - Release Date: 8/2/2002


  Return to Index