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

[Solved] allow raddatePicker to be nothing

2 Answers 206 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 13 Apr 2012, 04:19 PM
I am tring to save information based on if they pick a date back inot the Db.  So I am checking on the selectedvalue of the raddatepicker but it gives me this error when I do not have a date in there.

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

2 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 18 Apr 2012, 09:17 AM
Hello Kevin,

Please try using RadDatePicker.DbSelectedDate instead of SelectedDate and verify if this makes any difference in your case.

Regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
imran
Top achievements
Rank 1
answered on 27 Jun 2014, 07:12 AM
Hi Maria,

Works for me. Thanks
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
imran
Top achievements
Rank 1
Share this question
or