Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Another topic about getting data from ItemTemplate in DataGrid

Reply
Thread Tools

Another topic about getting data from ItemTemplate in DataGrid

 
 
Isoaxis@gmail.com
Guest
Posts: n/a
 
      10-03-2005
I've read the 1000's of topics about accessing the text contained in
ItemTemplates, but I'm still having a problem.

Here's an excerpt my ASPX code:

<ItemTemplate>
<asp:Label ID="lblAppliesTo" Runat="server">
<%# DataBinder.Eval(Container, "DataItem.Manufacturer") %>&nbsp;
<%# DataBinder.Eval(Container, "DataItem.Model") %>
</asp:Label>
</ItemTemplate>

Here's my codebehind:

Label lblAppliesTo =
(Label)e.Item.Cells[3].FindControl("lblAppliesTo");
string appliesTo = lblAppliesTo.Text;

The index is correct.
The page displays the data in the grid correctly upon page load.

Here's the funny part. The above code returns an empty string for
appliesTo, but I can set the text of the label in this method without a
hitch and display the changed value. It's like it found the control,
but won't give me the current text.

Any ideas?


thanks,
..brit

 
Reply With Quote
 
 
 
 
Isoaxis@gmail.com
Guest
Posts: n/a
 
      10-03-2005
The C# code above is located in the ItemCommand method.


..brit

 
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
can code inside a Repeater's ItemTemplate modify controls in the ItemTemplate? Bennett Haselton ASP .Net 1 09-24-2004 01:59 AM
Getting the value of another cell in Grid in ItemTemplate msnews.microsoft.com ASP .Net 1 08-11-2004 12:42 AM
Getting the value of another cell in Grid in ItemTemplate msnews.microsoft.com ASP .Net Web Controls 1 08-11-2004 12:42 AM
Getting the value of another cell in Grid in ItemTemplate msnews.microsoft.com ASP .Net Datagrid Control 1 08-11-2004 12:42 AM
Getting the value from ItemTemplate of DataList Vannela ASP .Net 1 12-12-2003 02:57 PM



Advertisments