hi,
i am not able to get rowindex of grid, i used onclick of link button event.
here i ma code..
CellSpacing="10" Width="580px" ShowHeader="False"
OnRowDataBound="GridView1_RowDataBound"
OnPageIndexChanging="gvPageIndexChanged" AllowPaging="True" PageSize="15">
LastPageText=" >>" NextPageText=" Next"
PreviousPageText="Prev " />
CommandName="" Text="Reply" OnClick = "lnkReply_Click">
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
mihir soniPosted May 10, 2010, 12:54 AM
In asp.net 2.0 row comand will be like this
protected void gridcommand(object sender, GridViewCommandEventArgs e)
here you can't get any property like e.RowIndex or e.Keys
But if you look at other specific event like OnRowUpdating OnRowDeleted ,properties like e.RowIndex or e.Keys are available so it will be easy to retrieve the values.you dont have to worry about this there is work around for getting this values in the command event ,i know that if you are using Gridview then you will definetly come across situation where you need to use the command event other than normal edit update and delete events.
thfollowing code sample will help you to retrieve those
protected void gridcommand(object sender, GridViewCommandEventArgs e)
{
GridViewRow row = (GridViewRow)((Control)e.CommandSource).Parent.Parent;
GridView gv = (GridView)(e.CommandSource);
string s = gv.DataKeys[row.RowIndex][0].ToString();
}