Object reference not set to an instance of an object.-error

Posted by Parthibansk under ASP.NET on 12/5/2012 | Points: 10 | Views : 707 | Status : [Member] | Replies : 5
i get above error when i build this code

int termsid = Convert.ToInt32(gvterms.DataKeys[e.RowIndex].Value.ToString());




Responses

Posted by: Ranjeet_8 on: 12/5/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Object reference not set to an instance of an object
Indicates whether a specified string/int is Nothing, empty, or consists only of white-space characters.
Or
plz Share your page design and code.

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

Posted by: Pavanandey on: 12/5/2012 [Member] Bronze | Points: 25

Up
0
Down
Check what value gvterms.DataKeys[e.RowIndex].Value.ToString() is giving.

Thanks
Pavan Kumar
Mark Answer if this fits the need

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

Posted by: Manoj_B on: 12/5/2012 [Member] Starter | Points: 25

Up
0
Down
hii.

write the follwing code

int termsid = Convert.ToInt32(gvterms.DataKeys[e.Row.RowIndex].Value.ToString());


Thanks & Regards
Manoj Kumar

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

Posted by: Alexhitc8 on: 12/6/2012 [Member] Starter | Points: 25

Up
0
Down
this is because "gvterms" or "DataKeys" is null when you read its value. Please check them. Hope this hints could solve your problem.

Regards,
Alex

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

Posted by: Sandhyab on: 12/11/2012 [Member] Starter | Points: 25

Up
0
Down
I think you are trying to access variable which is set to null. Please once check wheather it is givinh value.

Thanks & Regards

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

Login to post response