Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gridview row throwing an error

Lets start by saying that I am debugging someone else's code :-) The error occurs at the code routine that is attempting to export data from a gridview to an excel file.

GridView gv = new GridView();
Table table = new Table();
int maxRow = 60000;
int gvrow = Data().Tables[0].Rows.Count;  

The error is occuring at Data().Tables[0].Rows.Count

The error in the immediate window is:
? Data().Tables[0].Rows.Count
A first chance exception of type 'System.FormatException' occurred in System.Data.dll 'Data()' is null

The error message is:
System.NullReferenceException was unhandled by user code Message="Object reference not set to an instance of an object."

Any ideas what is wrong here?

like image 256
user279521 Avatar asked Aug 04 '26 13:08

user279521


1 Answers

Data() returns null. Fix that.

like image 180
thelost Avatar answered Aug 06 '26 03:08

thelost



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!