1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

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>
    SEMrush
     
    alanX, Jul 21, 2006 IP
    SEMrush
  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