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

Null dates

1 Answer 62 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 09 Jul 2009, 08:29 PM
We are having the null date issue with the RAD Date Picker I have read about on the forums, the example you guys have at this link "http://demos.telerik.com/aspnet-ajax/calendar/examples/datepicker/databinding/defaultcs.aspx" shows a solution for a DataTable as the source, we are using a SqlDataSource for ours can you explain how I would use this with a SqlDataSource since it doesn't have a rows property?

Protected Sub RadGrid1_UpdateCommand(ByVal source As ObjectByVal e As UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand 
        Dim picker As RadDatePicker = CType(e.Item.FindControl("picker1"), RadDatePicker) 
        Dim newDate As Object = picker.DbSelectedDate 
 
        DataSource1.Rows(e.Item.DataSetIndex)("Dates") = IIf(newDate Is Nothing, DBNull.Value, newDate) 
    End Sub 


Thanks!
Sam

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 13 Jul 2009, 12:39 PM
Hello Sam,

The example in the demo page inserts a date object directly into the table cell. For SQL sources, you will need to pass the value as a string parameter to the SQL UpdateCommand:

string dateVal = newDate == null ? "NULL" : "#" + ((DateTime)newDate).ToShortDateString() + "#"
string sqlComm = "UPDATE [MyTable] SET [Date] = " + dateVal + "WHERE [Id] = 12"

Best wishes,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Calendar
Asked by
Sam
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or