This is a migrated thread and some comments may be shown as answers.

GridDateTimeColumn check for null in code behind

2 Answers 115 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Philip Senechal
Top achievements
Rank 1
Philip Senechal asked on 23 Jul 2008, 05:33 PM
I have a procedure that runs in the ItemDataBound event for my grid. It's purpose is to color code a status field by checking the due date and today's date to see if the request is past due.

The due date is being displayed in a GridDateTimeColumn, however, NULL is a valid value in this field. There is no editing in this grid...it's for display purposes only.

I can't seem to figure out how to check in my code behind if there is a date in the GridDateTimeColumn or not. I tried to cast the field as a RadDatePicker using:

DirectCast(item("due_date").Controls(0), RadDatePicker)

but I get an error:

Specified argument was out of the range of valid values.
Parameter name: index

My code behind is in VB. Can you tell me how to check a GridDateTimeColumn for a null value in code behind? Thanks.

2 Answers, 1 is accepted

Sort by
0
Philip Senechal
Top achievements
Rank 1
answered on 23 Jul 2008, 07:04 PM
I found it.

I was checking for an empty string and a single space string. I was even checking for the length of the field. It ends up that it renders as  . You have to actually check for that value as " " not " ". It must not generate a length value when it's set to this either.

Weird...anyways, that's the deal.
0
Christopher Lee
Top achievements
Rank 1
answered on 12 Jan 2014, 10:18 PM
Thanks, thank helped me just resolve the same problem!!

Chris
Tags
Grid
Asked by
Philip Senechal
Top achievements
Rank 1
Answers by
Philip Senechal
Top achievements
Rank 1
Christopher Lee
Top achievements
Rank 1
Share this question
or