Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

How to find which button was clicked in a repeater itemtemplate and find the data of textbox
In my repeater I have a button and two textboxes. I entered the texbox values manually then click the send button to send the mail.


Please help me.
Thank you.
Posted
Updated 31-May-14 20:29pm
v4

1 solution

With this you are at least one step further:

Here is the aspx page repeater Object:

XML
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="test999base" OnItemCommand="Repeater1_ItemCommand">
            <ItemTemplate>
                <asp:TextBox runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "AutoId")%>'></asp:TextBox>
                <asp:TextBox runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "datafield2")%>'></asp:TextBox>
                <asp:Button ID="Button1" runat="server" Text="Button" CommandName="select" />
            </ItemTemplate>
        </asp:Repeater>




set the OnItemCommand="Repeater1_ItemCommand" in the repeater declaration and make a Method in code behind like this:

C#
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "select")
            {
                Button butt = (Button)e.CommandSource;
                string id = butt.ClientID;
                Response.Write("You clicked a button " + id);
            }
        }



That way, you have at least caught the button click.
 
Share this answer
 
Comments
NagaRaju Pesarlanka 1-Jun-14 1:45am    
I entered textbox values manually. Then click the send button I want to send the mail.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900