Posted on: 5/24/2013 4:20:41 AM | Views : 272

I have some NULL values in date datatype field of table
Eg. table name is device_info contains field as po_no(nvchar(15)), po_date(date),sdate(date)... sdate can be NULL
but during the time of binding the values in the gridview i am facing the problem as 
Conversion from type 'DBNull' to type 'Date' is not valid. My vb.net code is as 
If e.Row.RowType = DataControlRowType.DataRow Then ctrl_date = Session("lcl_date") If Session("lcl_date")IsNot Nothing Then ctrl_date = Session("lcl_date") End If Dim podate As DateTime = DataBinder.Eval(e.Row.DataItem, "podate") Dim sdate As DateTime = DataBinder.Eval(e.Row.DataItem, "sdate")
Dim lbl5 As Label = CType(e.Row.FindControl("Label5"), Label) Dim lbl6 As Label = CType(e.Row.FindControl("Label6"), Label)//Error Line
lbl5.Text = p ...

Go to the complete details ...