
Untitled
By: a guest on
Jun 17th, 2012 | syntax:
None | size: 0.91 KB | hits: 17 | expires: Never
Command behind a GridView ButtonField
<asp:ButtonField ButtonType="Image" ImageUrl="~/Images/pdf.png" CommandName="pdf_click" />
protected void pdf_click(object sender, EventArgs e)
{
lblWelkom.Text = "Succes!";
}
void GridView1_RowCommand(Object sender, GridViewCommandEventArgs e)
{
// If multiple buttons are used in a GridView control, use the
// CommandName property to determine which button was clicked.
if(e.CommandName=="pdf_click")
{
// Convert the row index stored in the CommandArgument
// property to an Integer.
int index = Convert.ToInt32(e.CommandArgument);
// Retrieve the row that contains the button clicked
// by the user from the Rows collection.
GridViewRow row = ContactsGridView.Rows[index];
// Now you have access to the gridviewrow.
}
}
int index = Convert.ToInt32(e.CommandArgument);
int ServerID = Convert.ToInt32(GridView1.DataKeys[index].Value);