Reputation: 2371
Is this possible to send a DB null to a integer variable.
I'm calling a function
private void BindGridView(String Fromdate, String Todate, int IsPending)
On pageload I show the both detail (ispending or not pending). For this I need to pass null.
Is there need to change the signature of function?
Upvotes: 3
Views: 8209
Reputation: 83366
Make the int parameter nullable, then check for a value when calling your sproc:
private void BindGridView(String Fromdate, String Todate, int? IsPending) {
and then
cmd.Parameters.AddWithValue("@intParam",
IsPending.HasValue ? (object)IsPending.Value : DBNull.Value);
Upvotes: 5
Reputation: 9129
Try a Nullable Type. In C# you can use the question mark. Instead of Nullable<int> you can write int ?
private void BindGridView(String Fromdate, String Todate, int ? IsPending)
Upvotes: 0