How to get the TestBox ID inside ItemTemplate: asp.net

Discussion in 'C#' started by alanX, Jul 21, 2006.

  1. #1
    Hi all,
    i created some TextBox inside "ItemTemplate" tag using C#, But when i want to get such TextBox's Value. I found it don't allow me to call the TestBox ID directly. (only one row in"DataGrid")
    How can get the values of such TextBox inside "ItemTemplate?


    <script ..>
    private void Function1(Object sender, EventArgs E)
    {
    Label1.Text=Text1.Text; <--can not detect ID "Text1"
    }
    </script>

    <asp:DataGrid ID="DataGrid1" runat="server"
    .
    <asp:TemplateColumn>
    <ItemTemplate>
    .
    <asp: TextBox ID="Text1"....... runat="server">...
    .
    </ItemTemplate>
    </asp:TemplateColumn>
    .
    </asp:DataGrid>
     
    alanX, Jul 21, 2006 IP
  2. benjymouse

    benjymouse Peon

    Messages:
    39
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    TextBox tb = (TextBox) grid1.Items[0].FindControl("Text1");
    Code (markup):
     
    benjymouse, Jul 22, 2006 IP