c# 4.0 - How to bind DBnull values to grid view? -


i facing struggle bind values grid retrieved data base. have database column of type datetime nullable. so, when trying bind null value, throwing error while adding column value object property . so, before adding values fetched database, using function converts value default type before adding object. since , default value datetime type 1/1/0001 12:00:00 . so, ever null values present , getting value field.

how solve issue? please give sugesstions.

to explain scenario , adding piece of code here.

public static t getvalue<t>(object o) {     t val = default(t);      if (o != null && o != dbnull.value)     {         val = (t)o;     }     return val; } 

this helper function using while reading data data reader.

since declared datetime nullable, instead of converting datetime,convert using datetime?

thus allows datetime values null values


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -