We use RadGrid to populate 2500 rows from the DB with a gridtemplatecolumn containing a RadDatePicker with name "dtpStart"
How do we trigger the RadDatePicker event, when it is changed so that we change a value of other Datepicker in the same row..
Need Solution......Thanks
6 Answers, 1 is accepted
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/accessingcellsandrows/defaultcs.aspx
When I have date pickers and not combos, I listen for SelectedDateChanged event of the first picker and change the value in the other in the row inside the select date handler as before.
Hope I am helpful,
Prangadj
The link show and works in the edit mode....in my case the datepicker's are in the cell directly,i change that without clicking edit
Since more changes will occur at a time where i can't keep editing each row seperately...
As Prangadj mentioned in the previous reply, you can achieve this by attaching OnSelectedDateChanged event to RadDatePicker. In the event handler, access the data item using NamingContainer property of RadDatePicker and then access the other DatePicker using FindControl() method.
Here is the code details:
ASPX:
<
telerik:GridTemplateColumn
>
<
ItemTemplate
>
<
telerik:RadDatePicker
ID
=
"RadDatePicker1"
runat
=
"server"
OnSelectedDateChanged
=
"RadDatePicker1_SelectedDateChanged"
>
</
telerik:RadDatePicker
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
C#:
protected
void
RadDatePicker1_SelectedDateChanged(
object
sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
{
RadDatePicker datePicker1 = (RadDatePicker)sender;
GridDataItem item = (GridDataItem)datePicker1.NamingContainer;
RadDatePicker datePicker2 = (RadDatePicker)item.FindControl(
"RadDatePicker2"
);
//accessing other RadDatePicker
}
Thanks,Princy.
Hi Princy,
<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="100px" />
<telerik:GridTemplateColumn HeaderText="Start" UniqueName="Start">
<ItemTemplate>
<telerik:RadDatePicker ID="RadDatePicker1" runat="server" AutoPostBack="true" OnSelectedDateChanged="RadDatePicker1_OnSelectedDateChanged">
</telerik:RadDatePicker>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Finish" UniqueName="Finish">
<ItemTemplate>
<telerik:RadDatePicker ID="RadDatePicker2" runat="server">
</telerik:RadDatePicker>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
how to get Estimated_Duration (third column) value from RadDatePicker1_OnSelectedDateChanged (same row)
Best Regards
Raghu
You can use the following approach to achieve this requirement:
protected
void
RadDatePicker1_SelectedDateChanged(
object
sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
{
RadDatePicker picker = sender
as
RadDatePicker;
GridDataItem item = picker.NamingContainer
as
GridDataItem;
TableCell cell = item[
"Estimated_Duration"
];
string
value = cell.Text;
DateTime dateValue;
if
(DateTime.TryParse(value,
out
dateValue))
{
// execute custom logic with the date
}
}
I hope this will prove helpful.
Regards,
Eyup
Telerik