PDA

Click to See Complete Forum and Search --> : Converting datarow results from null to string?


hellswraith
Mar 26th, 2003, 12:40 PM
Hello,
I have a datarow that I get back from the database. It contains varchar's, int's, datetime's, and char types. What I would like to do is convert all the string types (varchar) that are null into blank strings.

Is there an easy way to go through the items in the datarow and convert the null strings into blank strings?

I am currently doing this:

if(dr["myItem"] == null)
myLabel.Text = "";
else
myLabel.Text = dr["myItem"].toString();

It sucks having to do that for each of the strings that could be null. I have 10 items in the datarow that are allowed to be null.
I am hoping there is an easy foreach statement or something I can do.