In the gdview_RowEditing and gdview_RowDeleting event, we have used the below code to retrieve categoryid from datakey of GridView,
int catid = int.Parse(gdview.DataKeys[e.RowIndex].Value.ToString());
datakey at rowcommand
-------------------------
Control ctl = e.CommandSource as Control;
GridViewRow CurrentRow = ctl.NamingContainer as GridViewRow;
object objTemp = gvUsers.DataKeys[CurrentRow.RowIndex].Value as object;
if (objTemp != null)
{
string id = objTemp.ToString();
//Do your operations
}
--------
or
--------
GridViewRow grArtist = ((Control)
(e.CommandSource)).NamingContainer as GridViewRow;
//Check if command raised by DataRow or not
if (grArtist.RowIndex != -1)
{
intUserGridID =
int.Parse(gvArtist.DataKeys[grArtist.RowIndex].Values
[AdminConstantKeys.UserID].ToString());
------------------------
No comments:
Post a Comment