When I try to place a null value into my datagrid, I get this error. Is there a way around this?
Public member 'ToShortDateString' on type 'DBNull' not found
Printable View
When I try to place a null value into my datagrid, I get this error. Is there a way around this?
Public member 'ToShortDateString' on type 'DBNull' not found
Sounds like you are attempting to convert that to a short date time.
Search your code for toShortDateString and when you find it, see if it would be accessing that field. If so, then you need to do an IF statement. if not isdbnull(...) then ...
heres the code for the column in the datagrid. It's on the HTML side. Can I do a isDbNull check on it still?
Code:<asp:TemplateColumn SortExpression="DISPLAY_START_DATE" HeaderText="DISPLAY START DATE">
<ItemTemplate>
<%# Container.DataItem ("Display_Start_Date").ToShortDateString()%>
</ItemTemplate>
</asp:TemplateColumn>
<%# IIF(IsDBNull(Container.DataItem ("Display_Start_Date")), "", Container.DataItem ("Display_Start_Date").ToShortDateString() %>
I'm getting the same error. It bombs out when I try to bind the data at this line: DataGrid1.DataBind(). Could it be cause the codes on the HTML side?
Public member 'ToShortDateString' on type 'DBNull' not found
Perhaps this is what you are looking for:
Code:<asp:BoundColumn DataField="Display_Start_Date" HeaderText="DISPLAY START DATE" DataFormatString="{0:d}"></asp:BoundColumn>