Another topic about getting data from ItemTemplate in DataGrid

Discussion in 'ASP .Net' started by Isoaxis@gmail.com, Oct 3, 2005.

  1. Guest

    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
    , Oct 3, 2005
    #1
    1. Advertising

  2. Guest

    The C# code above is located in the ItemCommand method.


    ..brit
    , Oct 3, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vannela
    Replies:
    1
    Views:
    539
    Oleg Medyanik
    Dec 12, 2003
  2. msnews.microsoft.com
    Replies:
    1
    Views:
    1,432
    Ken Cox [Microsoft MVP]
    Aug 11, 2004
  3. Bennett Haselton
    Replies:
    1
    Views:
    5,312
    Joe Fallon
    Sep 24, 2004
  4. msnews.microsoft.com

    Getting the value of another cell in Grid in ItemTemplate

    msnews.microsoft.com, Aug 9, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    134
    Ken Cox [Microsoft MVP]
    Aug 11, 2004
  5. msnews.microsoft.com

    Getting the value of another cell in Grid in ItemTemplate

    msnews.microsoft.com, Aug 9, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    122
    Ken Cox [Microsoft MVP]
    Aug 11, 2004
Loading...

Share This Page