Click here to Skip to main content
16,009,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When i delete a row from gridview im getting this error...plz help me to solve this



C#
protected void grdClientDetails_RowDeleting(object sender, GridViewDeleteEventArgs e)
   {

       int int32Id = Convert.ToInt32(grdClientDetails.DataKeys[e.RowIndex].Value);

       ClsClientReg obj = new ClsClientReg();
       obj.DeleteClient(int32Id);

   }



Thanks

[edit]SHOUTING removed - OriginalGriff[/edit]
Posted
Updated 26-Jan-14 23:41pm
v3
Comments
OriginalGriff 27-Jan-14 5:41am    
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously.

Quote:
ClsClientReg obj = new ClsClientReg();
obj.DeleteClient(int32Id);

If the first line creates (as it looks) an empty object, the second line is destined to fail.
 
Share this answer
 
The Gridview datakeys collection seems to be empty.

Set the DataKeyNames property and then access it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900