If I have listview control with a button in the item template, how do I handle the onclick events for each of the buttons that ends up getting generated in the listview?
+1
A:
Same way you do with every other button:
<asp:Button ID="templateButton" runat="server" OnClick="templateButton_OnClick"/>
Except that you will need to determine which button was clicked in the handler itself.
protected void templateButton_OnClick(object sender, EventArgs e)
{
Button myButton = (Button)sender;
}
Matthew Jones
2009-06-24 21:23:38
A:
You can use CommandArgument property of the button control to specify which button clicked.
This example shows how to get values from command argument within listview control.
Canavar
2009-06-24 21:26:53