C# Get TextBox Text From Repeater

The Repeater

   <asp:Repeater ID="mygrid" OnItemCommand="MyGrid_ItemCommand" runat="server">
            <asp:TextBox ID="x1" Text='<%# Eval("namef") %>' runat="server" />
            <asp:TextBox ID="x2" Text='<%# Eval("depotf") %>' runat="server" />
            <asp:Button ID="MyButton" Text="Submit" runat="server" />
            <br />
            <br />

The Code

    protected void MyGrid_ItemCommand(object source, RepeaterCommandEventArgs e)
        TextBox mytextbox = e.Item.FindControl("x1") as TextBox;
        mytext.Text = mytextbox.Text;

So note as we declare the repeater in the HTML we add OnItemCommand which points to the function. Also note the function uses RepeaterCommandEventArgs and not the usual EventArgs

Reader's Comments

Post Your Comment Posts/Links Rules



Add a RELEVANT link (not required)

Upload an image (not required)

No uploaded image
Real person number
Please enter the above number below

Admin Ren's Biking Blog