I was trying to follow the same code here on a telerik web site, becuase I need to do the smae thing, however it keeps telling me that I cannot get ahold of the raddatePicker that I put on the editform template, I am guessing its cause i am binding to a datatable. I need to be able to get a hold of the raddate and time pickers and store them in a session datatable until i insert them into a database.
<
telerik:RadGrid
ID
=
"myradGrid"
runat
=
"server"
Skin
=
"Web20"
CssClass
=
"CentGrid50"
Visible
=
"false"
>
<
MasterTableView
AutoGenerateColumns
=
"true"
ShowHeadersWhenNoRecords
=
"true"
CommandItemDisplay
=
"Top"
>
<
EditFormSettings
EditFormType
=
"Template"
>
<
FormTemplate
>
<
table
>
<
tr
>
<
td
>
<
telerik:RadDatePicker
ID
=
"dtbegin"
runat
=
"server"
Width
=
"100px"
></
telerik:RadDatePicker
>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
telerik:RadTimePicker
ID
=
"dtTimeBegin"
runat
=
"server"
Width
=
"100px"
>
<
TimeView
runat
=
"server"
Interval
=
"00:30:00"
></
TimeView
>
</
telerik:RadTimePicker
>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
telerik:RadTimePicker
ID
=
"RadTimePicker1"
runat
=
"server"
Width
=
"100px"
>
<
TimeView
runat
=
"server"
Interval
=
"00:30:00"
></
TimeView
>
</
telerik:RadTimePicker
>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
asp:LinkButton
ID
=
"lnkSubmit"
runat
=
"server"
text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "Insert", "Update") %>'
CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update")%>'></
asp:LinkButton
>
<
asp:LinkButton
ID
=
"lnkCancel"
runat
=
"server"
CausesValidation
=
"false"
CommandName
=
"Cancel"
Text
=
"Cancel"
></
asp:LinkButton
>
</
td
>
</
tr
>
</
table
>
</
FormTemplate
>
</
EditFormSettings
>
</
MasterTableView
>
</
telerik:RadGrid
>
Protected Sub myradGrid_NeedDataSource(sender As Object, e As GridNeedDataSourceEventArgs) Handles myradGrid.NeedDataSource
Dim dt As New DataTable
dt.Columns.Add("Date Begin")
dt.Columns.Add("Time Begin")
dt.Columns.Add("Time End")
If Session("Table") IsNot Nothing Then
dt = DirectCast(Session("Table"), DataTable)
End If
myradGrid.DataSource = dt
'populate RadGrid with datatable
Session("Table") = dt
End Sub
Heres my code to try to get at the insert into the datatable but it will not allow me to get at the raddate or time pickers, says cannot be converted from table cell.
Protected Sub myradGrid_ItemCommand(sender As Object, e As GridCommandEventArgs) Handles myradGrid.ItemCommand
If (e.CommandName = RadGrid.PerformInsertCommandName) Then
Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
Dim dtbegin As RadDatePicker = DirectCast(editedItem("dtbegin"), RadDatePicker)
Dim dt As DataTable
dt = DirectCast(Session("Table"), DataTable)
Dim drValues As DataRow = dt.NewRow()
drValues("Date Begin") = dtbegin.Text
drValues("Time Begin") = timeBegin.Text
drValues("Time End") = timeEnd.Text
dt.Rows.Add(drValues)
'adding new row into datatable
dt.AcceptChanges()
Session("Table") = dt
myradGrid.Rebind()
End If
End Sub