Bassically what I want to do is rotate through my radgrid and if they have picked a date then save information to the DB otherwise just go to the next row. But this error pops if no date is picked.
Nullable object must have a value.
Line 238: If TempDt.SelectedDate.Value > Nothing Then
Protected Sub lnkSaveTemp_Click(sender As Object, e As System.EventArgs) Handles lnkSaveTemp.Click
For Each row As GridDataItem In myRadGrid.Items
Dim Id As Integer = row.GetDataKeyValue("intIssuedId")
Dim TempDt As RadDatePicker = DirectCast(row.FindControl("DatePicker"), RadDatePicker)
Dim TNote As TextBox = DirectCast(row.FindControl("txtNotes"), TextBox)
If TempDt.SelectedDate.Value > Nothing Then
sql = "Update Drat_Issued set dtRecoverTemp = '" & sanitizeString(TempDt.SelectedDate.Value) & "', strNotes = '" & sanitizeString(TNote.Text) & "' where intIssuedId = " & Id
Response.Write(sql)
insertUpdateDelete(sql)
End If
Next
End Sub
7 Answers, 1 is accepted

Please check below code snippet.
RadDatePicker rdp1 =
new
RadDatePicker();
if
(rdp1.SelectedDate !=
null
&& rdp1.SelectedDate.GetValueOrDefault() != DateTime.MinValue)
{
}
OR
Dim
rdp1
As
New
RadDatePicker()
If
rdp1.SelectedDate IsNot
Nothing
AndAlso
rdp1.SelectedDate.GetValueOrDefault() <> DateTime.MinValue
Then
End
If
Thanks,
Jayesh Goyani


Can you please elaborate your scenario?
Thanks,
Jayesh Goyani

Here is one...
function ClientSubmit(sender, args) {
var tdate = $find("<%=RDP_TerminationDate.ClientID %>");
var rdate = $find("<%=RDP_ResignationDate.ClientID %>");
if (tdate.get_selectedDate() == null && rdate.get_selectedDate() == null) {
radalert("Please select a termination or resignation date.<br/><br/>Thank you.", 300, 180, "Attention", null, null);
if (tdate.get_selectedDate() == null && rdate.get_selectedDate() != null) {
tdate.showPopup();
}
else {
rdate.showPopup();
}
return args.set_cancel(true);
}
}
Either one of these fields are NOT null however, the control thinks it is...
The following seems to work fine for me and below is attached a video that shows the expected behavior. Could you take a look at my test and see whether I am missing something? If so, can you show me what it is and what the problematic scenario is, so I can take a look?
<telerik:RadDatePicker runat=
"server"
ID=
"RDP_TerminationDate"
></telerik:RadDatePicker>
<telerik:RadDatePicker runat=
"server"
ID=
"RDP_ResignationDate"
></telerik:RadDatePicker>
<telerik:RadButton runat=
"server"
ID=
"rb1"
OnClientClicking=
"ClientSubmit"
Text=
"Submit"
></telerik:RadButton>
<telerik:RadWindowManager runat=
"server"
ID=
"rwm1"
></telerik:RadWindowManager>
<script>
function
ClientSubmit(sender, args) {
var
tdate = $find(
"<%=RDP_TerminationDate.ClientID %>"
);
var
rdate = $find(
"<%=RDP_ResignationDate.ClientID %>"
);
alert(tdate.get_selectedDate());
alert(rdate.get_selectedDate());
//you may want to use a logical OR operator instead of AND, depending on the logic that is desired
//for example:
//if (tdate.get_selectedDate() == null || rdate.get_selectedDate() == null) {
if
(tdate.get_selectedDate() ==
null
&& rdate.get_selectedDate() ==
null
) {
radalert(
"Please select a termination or resignation date.<br/><br/>Thank you."
, 300, 180,
"Attention"
,
null
,
null
);
//you may want to execute this logic in the callback function of the radalert
if
(tdate.get_selectedDate() ==
null
&& rdate.get_selectedDate() !=
null
) {
tdate.showPopup();
}
else
{
rdate.showPopup();
}
args.set_cancel(
true
);
}
}
</script>
Regards,
Marin Bratanov
Progress Telerik

Thanks (sorry for the late response) but the user is required to select either the tdate or the rdate. Either one is acceptable. That's why I check to see if they both are empty.
The problem was that get_selectedDate() would not show/capture the date that I had selected.
In such a case, the OR operator is perfect, I just mentioned this because the majority of cases I come across validation requires both fields.
If you still have issues with this scenario, could you post here the Telerik controls version that the project is using and the relevant markup+JavaScript that causes the problem so I can take a look? You can modify my previous snippet if that's easier for you than extracting the actual problem.
Regards,
Marin Bratanov
Progress Telerik