protected void myRowCommand(object sender, GridViewCommandEventArgs e)
{
Button lnkBtn = (Button)e.CommandSource; // the button
GridViewRow myRow = (GridViewRow)Btn.Parent.Parent; // the row
GridView myGrid = (GridView)sender; // the gridview
string ID = myGrid.DataKeys[myRow.RowIndex].Value.ToString(); // value of the datakey
switch (e.CommandName)
{
case "Delete":
// ID is your primary key. call your delete function and pass ID to delete DB record
break;
}
}
what is this "Parent.Parent" ? what does it mean and hwo it helps ?
Go to the complete details ...