Home > DeveloperSection > Forums > Access textbox in itemtemplate
Ashish Pandey

Total Post:128

Posted on    August-19-2014 3:12 AM

 ASP.Net ASP.Net 

 1 Reply(s)
 665  View(s)
Rate this:

I have 2 textboxes and a button in a row, and a Repeater dynamically generates some rows at Page_Load function.

<asp:Repeater id="Repeater1" runat="server">



            <td><asp:Label CssClass="form-control" disabled="true" runat="server"><%# DataBinder.Eval(Container.DataItem, "sid") %></asp:Label></td>

            <td><asp:TextBox CssClass="form-control" runat="server" ID="quiz1"></asp:TextBox></td>

            <td><asp:TextBox CssClass="form-control" runat="server" ID="quiz2"></asp:TextBox></td>

            <td><asp:Button ID="add" CommandName="add" runat="server" OnClick="addQuiz" Text="Add" CssClass="btn btn-success btn-sm form-control"/></td>




How do I access the textboxes in the Repeater upon clicking the button in the row?

Pravesh Singh

Total Post:411

Posted on    August-19-2014 3:33 AM

Hi Ashish, 
try this:

protected void addQuiz(Object sender, EventArgs e)


    var btn = (Button) sender;

    var item = (RepeaterItem) btn.NamingContainer;

    var quiz1 = (TextBox) item.FindControl("quiz1");

    var quiz2 = (TextBox) item.FindControl("quiz2");


Don't want to miss updates? Please click the below button!

Follow MindStick