Connecting Tech Pros Worldwide Forums | Help | Site Map

How to Access Template Field Value In Gridview

Newbie
 
Join Date: Oct 2007
Posts: 1
#1: Oct 11 '07
I have a gridview component and it has a template field associated with it.

However when I used
gridview.Cells[i].Text it is null or balnk.

Also the template field has not control associated with it

here is the code:
<asp:TemplateField HeaderStyle-Width="1000px" HeaderStyle-Wrap="true" ItemStyle-Width="200" ItemStyle-HorizontalAlign="Center" HeaderStyle-CssClass="Header" >
<HeaderTemplate>
<!-- Extended Comments -->
FieldNumber1
</HeaderTemplate>
<ItemTemplate >
<%# DataBinder.Eval(Container.DataItem, "FieldNumber1")%>
</ItemTemplate>
<HeaderStyle BackColor="LightGray" CssClass="MyClass" />
</asp:TemplateField>

I have even tried making the width as 0(zero) pixels or adding a hidden column , used css to make it hidden too ,but cannot access it?

Any ideas or suggestions?

Please HELP
nateraaaa's Avatar
Expert
 
Join Date: May 2007
Location: Illinois
Posts: 663
#2: Oct 11 '07

re: How to Access Template Field Value In Gridview


What are you trying to accomplish with your TemplateField? The code that you posted does not really describe what you are trying to do with the DataBinder.Eval. I generally use DataBinder.Eval so that I can pass the value as a querystring to another page via the CommandArgument. Please provide the additional info and I will do my best to get you on the right track.

Nathan
Reply