Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
i want capture data from the textbox that is placed on the gridview so i am tring to get that i written like

string stcustid= ((TextBox)(Gridview1.FooterRow.FindControl("TxtCustId"))).Text;

i am getting error like

Object reference not set to an instance of an object.
please solve this error
thank you
Posted
Comments
ZurdoDev 22-Feb-12 14:16pm    
Need more details. Just debug it. It may be that FooterRow is null or it may be that TxtCustId is not found. Just use your watch window or your immediate window and you should be able to solve this very quickly.

Hi,

You should use some bullet proof solution. Check my previous answer[^] for similar problem...

Ra Selector class[^] is great thing to find/get controls on server side...
 
Share this answer
 
v2
Comments
Orcun Iyigun 22-Feb-12 14:42pm    
Your link is broken.
Martin Arapovic 22-Feb-12 14:52pm    
Yes, I saw that and because of that I put new link in this answer... :)
Tnx...
Most likely is that the control id is misspeled (case sensitivity also).Check piece by piece in debug.
Gridview1.FooterRow is not null and then Gridview1.FooterRow.FindControl("TxtCustId")) is not null. Based on that please see what is wrong.
Also make sure the control is available at the time of calling (is created). For eaxample if you try to call it on preinit the control is not created yet.
 
Share this answer
 
System.Web.UI.WebControls.TextBox txtBxText = (System.Web.UI.WebControls.TextBox)gridView.Rows[j].Cells[i].FindControl("txtbxID");
C#



Remember to loop through or give correct value of i and j
 
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