public static string GetString(string text) //text value comes from TextBox.Text
{
if ((text == null) || (text.Trim().Length == 0))
{
return string.Empty;
}
//return null;
// System.DBNull.Value;
return text;
}
This is giving me ""and not null. I want to store null in database and not "".
Return null from function
I have some textboxes. I want to read their value and find if they are null or not. If the value is empty I want to return null as I will be creating a dynamic insert Sql statement. I created the Datahelper class with various functions like
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
srikanth reddy9 pointsPosted Aug 25, 2006, 5:06 AM EDT
return DBNull.Value.ToString();