hmk
hmk

Reputation: 969

How to fillter the database null values of integer column in C# using if condition?

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
{
}

Upvotes: 0

Views: 1238

Answers (3)

NoviceProgrammer
NoviceProgrammer

Reputation: 3365

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

ex:

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

Upvotes: 0

Neha
Neha

Reputation: 2965

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

Hope it helps

Upvotes: 1

Chun Lin Yen
Chun Lin Yen

Reputation: 39

if you are using Entity Framework ,you could use

if(yourvalue.HasValue){ ...}

Upvotes: 0

Related Questions