I have a RadDatePicker inside my RadGrid, and I do a Update-All:
<
rad:GridTemplateColumn HeaderText="DateIn" DataField="DateIn" SortExpression="DateIn">
<EditItemTemplate>
<rad:RadDatePicker ID="RadDateTimePicker1" runat="server" Culture="English (United States)"
DbSelectedDate='<%# Bind("DateIn", "{0:D}") %>'>
<DateInput runat="server" />
update-all:
foreach (Telerik.Web.UI.GridEditableItem editedItem in rgJobInv.EditItems)
{
Hashtable newValues = new Hashtable();
e.Item.OwnerTableView.RetrieveNullAsDBNull = true;
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
but, null was passed to my stored procedure from the RadDatePicker, when I enter '8-28-2008'.
Please help.
Stanley
7 Answers, 1 is accepted
Binding a RadDatePicker, RadTimePicker, or RadDateTimePicker control to a data source is easy provided you use the DbSelectedDate property. It works almost like the SelectedDate one, but does not throw an exception when given a null value.
You can review the following help article and online example:
http://demos.telerik.com/aspnet/prometheus/Calendar/Examples/DatePicker/DataBinding/DefaultCS.aspx
http://www.telerik.com/help/aspnet-ajax/calendar_pickerdatabinding.html
Do not hesitate to write us if you have any questions
Kind regards,
Plamen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
you might missed my question. My code was compiled ok, and updating one row in RadGrid was OK, with RadDatePicker.
However, when using Update-all feature, "null" was passed from RadDatePicker, inside RadGrid, when I enter a date--"8-29-2008".
why a "null" value was passed from RadDatePicker?
thanks.
Stanley
When embedding RadDatePicker, RadTimePicker, and RadDateTimePicker controls inside a data-bound control, use a data-binding expression without the second argument "{0:D}"
Here is an example:
<rad:RadDatePicker |
ID="RadDateTimePicker1" |
runat="server" |
Culture="English (United States)" |
DbSelectedDate='<%# Bind("DateIn") %>'> |
................... |
All the best,
Plamen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Thank you for your help. I tried your suggestion, but it did not work.
Stanley
Unfortunately we are still unable to reproduce the problematic behavior you are experiencing. Please review the attached application and let me know if I am missing something.
Greetings,
Plamen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Hi Plamen,
<Columns>
<telerik:GridBoundColumn UniqueName="Task_ID" DataField="Task_ID" HeaderText="Task ID"
HeaderStyle-Width="50px" />
<telerik:GridBoundColumn DataField="Task_Name" HeaderText="Task Name" HeaderStyle-Width="200px" />
<telerik:GridBoundColumn DataField="Estimated_Duration" HeaderText="Estimated Duration"
HeaderStyle-Width="75px" />
<telerik:GridTemplateColumn HeaderText="Start" UniqueName="Start">
<ItemTemplate>
<telerik:RadDatePicker Width="100px" ID="RadDatePicker1" runat="server" AutoPostBack="true"
OnSelectedDateChanged="RadDatePicker1_OnSelectedDateChanged">
</telerik:RadDatePicker>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Finish" UniqueName="Finish">
<ItemTemplate>
<telerik:RadDatePicker Width="100px" ID="RadDatePicker2" runat="server">
</telerik:RadDatePicker>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Act Start" UniqueName="Start">
<ItemTemplate>
<telerik:RadDatePicker Width="100px" ID="RadDatePicker3" runat="server">
</telerik:RadDatePicker>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="ActFinish" UniqueName="Finish">
<ItemTemplate>
<telerik:RadDatePicker Width="100px" ID="RadDatePicker4" runat="server" AutoPostBack="true" OnSelectedDateChanged="RadDatePicker4_OnSelectedDateChanged">
</telerik:RadDatePicker>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Time Taken" UniqueName="Finish" HeaderStyle-Width="50px">
<ItemTemplate>
<asp:Label ID="lblTimeTaken" runat="server"></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Status" UniqueName="Finish">
<ItemTemplate>
<telerik:RadComboBox ID="rcStatus" runat="server" CssClass="clsEditField" AllowCustomText="false"
MarkFirstMatch="true" Width="100px" Height="85px">
<Items>
<telerik:RadComboBoxItem runat="server" Text="All" Value="0" />
<telerik:RadComboBoxItem runat="server" Text="Red" Value="1" />
<telerik:RadComboBoxItem runat="server" Text="Green" Value="2" />
<telerik:RadComboBoxItem runat="server" Text="Yellow" Value="3" />
</Items>
</telerik:RadComboBox>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
C#:
protected void RadDatePicker1_OnSelectedDateChanged(object sender, SelectedDateChangedEventArgs e)
{
RadDatePicker datePicker1 = (RadDatePicker)sender;
GridDataItem item = (GridDataItem)datePicker1.NamingContainer;
DateTime estimatedFinishDate = AddBusinessDays(Convert.ToDateTime(e.NewDate), Convert.ToInt32(item.Cells[4].Text) - 1);
RadDatePicker datePicker2 = (RadDatePicker)item.FindControl("RadDatePicker2");
datePicker2.SelectedDate = estimatedFinishDate.Date;
}
protected void RadDatePicker4_OnSelectedDateChanged(object sender, SelectedDateChangedEventArgs e)
{
DateTime ActStartDate = new DateTime();
DateTime ActFinishDate = Convert.ToDateTime(e.NewDate);
RadDatePicker datePicker1 = (RadDatePicker)sender;
GridDataItem item = (GridDataItem)datePicker1.NamingContainer;
RadDatePicker datePicker3 = (RadDatePicker)item.FindControl("RadDatePicker3");
ActStartDate = Convert.ToDateTime(datePicker3.SelectedDate);
int noOf = GetNumberOfWorkingDaysJeroen(ActStartDate, ActFinishDate);
item.Cells[9].Text = noOf.ToString();
}
in RadDatePicker4_OnSelectedDateChanged am setting item.Cells[9].Text, but only current row cell[9] text only showing correctly, remaining rows text(cell[9]) get clear .
Please let me know where am doing wrong.
Best Regards
Raghu Kiran
Which edit mode do you use? Could you elaborate on what exactly you want to achieve?
Regards,
Eyup
Telerik