0

I am passing data value, to a database, using integer data type (accepting null).

If in front-end I do not pass any integer it takes null value in db. While retrieving table data in front-end I am using if condition to filter the integer empty values. I have only integers to display, how to write the if condition?

int x;
if(x!=(which code this place write)
{
textbox.text=x; //x value not empty working if condition else goto else condition
}
else
{
}
3
  • what if condition you have tried? Commented Dec 13, 2011 at 6:37
  • 1
    Please rephrase your question. Edit your post and add code. Commented Dec 13, 2011 at 6:43
  • Why use if and not LINQ? Commented Dec 13, 2011 at 7:06

3 Answers 3

1
 if (dt.Rows[0]["ToAge"] == DBNull.Value)

Hope it helps

Sign up to request clarification or add additional context in comments.

Comments

0

if you are using Entity Framework ,you could use

if(yourvalue.HasValue){ ...}

1 Comment

It is not working for integers. Integers has not "HasValue" property
0

Not clear from your question but I guess you want to use DBNull

ex:

if(your value == System.DBNull.Value)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.