Get rowindex in rowcommand

Posted by Oswaldlily under ASP.NET on 5/8/2013 | Points: 10 | Views : 1517 | Status : [Member] | Replies : 1
protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
{
//How to get rowindex here..........
}




Responses

Posted by: Kmandapalli on: 5/8/2013 [Member] Silver | Points: 25

Up
0
Down
Hi,

One Way:

protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
{
GridViewRow gvr = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);
int RowIndex = gvr.RowIndex;
}

Second Way:

if you have built in command of gridview like insert,update delete,on row command you can following line code to get index.
int index = Convert.ToInt32(e.CommandArgument);

Third Way:

protected void OnRowCommand(object sender, GridViewCommandEventArgs e)
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow gvRow = GridView1.Rows[index];
}

Mark as Answer if satisfied...

Regards,
Shree M.


Kavya Shree Mandapalli

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response