1
Answer

Return null from function

Photo of Ajay Singh

Ajay Singh

18y
2.8k
1
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

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 "".  

Answers (1)

Next Recommended Forum