Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Error: Object reference not set to an instance of an object.
Code :
VB
Dim CustomerID As String = DirectCast(GridView1.Rows(e.RowIndex).FindControl("txtCustomerID"), TextBox).Text
Posted
Updated 27-Sep-13 7:24am
v3

This question seems to be hitting this forum with monotonous regularity at the moment; largely, I suspect, because of all the bad practices that seem to be taught in schools just now. I recommend you split the above statement into its constituent parts and then run it through your debugger to see which part is causing the failure.
 
Share this answer
 
Try This One


Label lblID = GridView1.Rows[e.RowIndex].FindControl("txtCustomerID") as Label;
 
Share this answer
 
you need to write full code. may be you forgotten there is some problem in connection string.
 
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