Monday, February 20, 2012

Problem with dataset

My data from this dataset works until I get to a column that has no value in it then it starts not showing the value in the three columns after the no value column. This is my code to handle the no value column.

if ((myDataset.Tables[0].Rows[i][j].ToString()) == "")

I'm not sure of the C# syntax, but try:

if ((myDataset.Tables[0].Rows[i][j] is DBNull)

|||

It ended up that because of a javascript issue it was entering a bunch of spaces in that column and therefore the column wasn't null or "" empty and I couldn't check the length cause of the spaces. So I replaced " " with "" (2 spaces with 0 spaces) then checked if length is less than 2. It worked perfect.

No comments:

Post a Comment