hey Navanit,
Assign Primarykey column name to DatakeyName property of GridView and try this on selectedIndexchanged event of GridView
int _gCode;
_gCode = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
or u can use this also..
int j = GridView1.SelectedRow.RowIndex;
_gCode = Convert.ToInt32(GridView1.DataKeys[j].Value);
hope this help u.