Find the Row index when you click a button in a gridview by using the following in the button click method in code behind
GridViewRow row = ((LinkButton)sender).Parent.Parent as GridViewRow;
Response.Write(row.RowIndex);
Other way to use it is to have a command Name(for ex:View) and a Command Argument for the button and then using the GridView_RowCommand(object sender, GridViewCommandEventArgs e) _
There you can use some thing like
if (e.CommandName.ToString().Equals("View"))
{
int currentRowIndex = Int32.Parse(e.CommandArgument.ToString());
}
Monday, May 24, 2010
Row Index on button click in a gridview
Labels:
button,
Command,
command Argument,
gridview,
index,
row index,
rowcommand
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment