|
-
Jan 9th, 2003, 11:29 AM
#1
Thread Starter
Frenzied Member
placing DbNull into "ToShortDateString'
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
-
Jan 9th, 2003, 12:53 PM
#2
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 ...
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Jan 9th, 2003, 01:17 PM
#3
Thread Starter
Frenzied Member
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>
-
Jan 9th, 2003, 01:31 PM
#4
<%# IIF(IsDBNull(Container.DataItem ("Display_Start_Date")), "", Container.DataItem ("Display_Start_Date").ToShortDateString() %>
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Jan 9th, 2003, 01:50 PM
#5
Thread Starter
Frenzied Member
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
-
Jan 9th, 2003, 02:53 PM
#6
Addicted Member
Perhaps this is what you are looking for:
Code:
<asp:BoundColumn DataField="Display_Start_Date" HeaderText="DISPLAY START DATE" DataFormatString="{0:d}"></asp:BoundColumn>
-Daryl
"Two More Rolls of Duct tape, and the world is mine!"
VB.NET Guru
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|