problems getting text from labels in datagrid control

Discussion in 'ASP .Net Web Controls' started by Charles, Jan 14, 2004.

  1. Charles

    Charles Guest

    I am having some problems with getting the text from a
    label inside of a datagrid control. I want to put the
    text of the label into an array.

    Here is part of the *.aspx file:
    <asp:TemplateColumn HeaderText="Last Name">
    <ItemTemplate>
    <asp:Label id=lblLName runat="server" Text='<%#
    DataBinder.Eval(Container, "DataItem.LName") %>'>
    </asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox id=LName CssClass=grid runat="server"
    Text='<%# DataBinder.Eval(Container, "DataItem.LName") %>'>
    </asp:TextBox>
    </EditItemTemplate>
    </asp:TemplateColumn>

    Just before the EditCommand event I want to get the
    current values of all (I have eight, but only show one
    here) labels. Right now in my EditCommand event I have:

    For I = 1 To e.Item.Cells.Count - 1
    Dim label1 As Label = DataGrid1.Items(I).Cells
    (0).Controls(1)
    CurrentValues(I) = label1.Text
    Next

    Before this line:

    DataGrid1.EditItemIndex = e.Item.ItemIndex

    How do I get a text value from a label from a datagrid
    control? I want to compare two arrays to find what
    information in the grid (edited row) has been changed. I
    am not sure if this is a good way, so if there is please
    share that with me.

    Thanks,
    Charles
    Charles, Jan 14, 2004
    #1
    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. tony collier
    Replies:
    2
    Views:
    366
    tony collier
    Jan 12, 2004
  2. darrel
    Replies:
    1
    Views:
    349
    Peter Blum
    Sep 3, 2004
  3. Neo
    Replies:
    0
    Views:
    336
  4. Bad Starter
    Replies:
    0
    Views:
    353
    Bad Starter
    Jul 18, 2006
  5. Keithb
    Replies:
    0
    Views:
    2,897
    Keithb
    Nov 4, 2006
Loading...

Share This Page