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

RadDatePicker inside of a Form Template

2 Answers 96 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Dale
Top achievements
Rank 1
Dale asked on 23 Nov 2016, 05:45 PM
I have a RadDatePicker inside of a Form Template.  I can access the dbselected value from code behind, though I want to take the month and day of the dbselected value and populate an asp:textbox with the month, and a RadNumericTextBox with the day.

 

The structure is

1. RadGrid

2. MasterTableView

3. EditFormSettings

4. Form Template

5. Then tables/rows/cells containing labels, textboxes, etc.

 

From code behind I can access all the asp and telerik items in the tables and retrieve any data for further use in my application by using the following code:

 

If e.CommandName = RadGrid.UpdateCommandName Then
            If TypeOf e.Item Is GridEditFormItem Then
                Dim item As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
                Dim theClient As TextBox = DirectCast(item.FindControl("txtClient"), TextBox)
                Dim theOrder As TextBox = DirectCast(item.FindControl("txtOrder"), TextBox)
              
  Dim theRadDateOrder As RadDatePicker = DirectCast(item.FindControl("RadDatePickerOrderDate"), RadDatePicker)

                etc.


I now have the value from the dbSelectedDate:

                Dim theDateOrderDate As DateTime = theRadDateOrder.DbSelectedDate
                Dim theDateOrderMonth As String = theDateOrderDate.ToString("MMMM")
                Dim theDateOrderDay As String = theDateOrderDate.Day

And I now have a month and I have a day broke out.

Now within the form template is an asp:textbox that I want to update/insert/place the month value into.  I also have  a RadNumericTextBox that I want to update/insert/place the day value into.

What I want to do is update the month and day on the form when the date is selected with the RadDatePicker.

All the above was figured out by searching the internet and putting the pieces together. 

I have not been able to find even a starting point on my question, it may be in the above code, but I do not see it yet.

My question is how do I do this from code behind as I cannot access the controls directly as they are within the Form Template?

 

Thank you for your time.  Dale

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 28 Nov 2016, 12:59 PM
Hello Dale,

You can achieve this requirement either on client and server side:

JavaScript:
You can examine the RadGridEditComboClientHideModified.zip web site sample provided in the following post:
http://www.telerik.com/forums/how-to-change-and-get-value-from-a-dropdownlist-in-a-radgrid-column#jIjRiaOYhkucLZ82pztwow

Code-behind:

Enable the AutoPostback property of the picker. Using its selected change event handler, you can access the grid item: (sender as RadDatePicker).NamingContainer as GridEditableItem. Once you have the instance of the grid edit form item, then you can just use FindControl get the textbox and the numbox:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-controls-in-editinsert-mode


I hope this will prove helpful.

Regards,
Eyup
Telerik by Progress
Telerik UI for ASP.NET Core is ready for Visual Studio 2017 RC! Learn more.
0
Dale
Top achievements
Rank 1
answered on 02 Dec 2016, 09:13 PM
Thank you this is just what I needed.
Tags
Date/Time Pickers
Asked by
Dale
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Dale
Top achievements
Rank 1
Share this question
or