I don't know why I have such a hard time grasping the fundamentals of radgrid when in edit/insert mode but I sure do. I do not see how to edit/trap the values I am editing. I am trying to work with a checkbox list that has the days of week in a gridtemplatecolum. I am using editForms mode as per tutorials. I can using the insert_command get the selected values and convert those to a string for sql_insert to a column, however I can't get the value out when in edit mode back into the list. ie. convert Monday,Tuesday into the checkbox list as I can't find the checkboxlist. I am using EditCommand. once i can find the control, reading it back in should not be a problem... its a matter of finding it.
Source
Dim appid As String |
Dim cblstr As String |
Protected Sub SqlDataSource1_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource1.Inserting |
e.Command.Parameters("@AppID").Value = Applicants1.appid |
e.Command.Parameters("@NotAvailalble").Value = cblstr |
End Sub |
Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting |
If Applicants1.appid IsNot Nothing Then |
appid = Applicants1.appid |
e.Command.Parameters("@AppID").Value = appid |
End If |
End Sub |
Protected Sub RadGrid1_EditCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.EditCommand |
If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then |
Dim cbl As CheckBoxList = (TryCast(e.Item, GridEditableItem)).Controls(0).FindControl("CBNotAvail") |
' this totally fails as it says it can't find the item |
End If |
End Sub |
Protected Sub RadGrid1_InsertCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.InsertCommand |
If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then |
Dim cbl As CheckBoxList = (TryCast(e.Item, GridEditableItem)).Controls(0).FindControl("CBNotAvail") |
cblstr = functions.CBListValues(cbl) |
End If |
End Sub |
Source
<telerik:GridTemplateColumn UniqueName="NotAvailable" HeaderText="Not Available" Visible="False"> |
<EditItemTemplate> |
<asp:CheckBoxList ID="CBNotAvail" runat="server" SelectedValue='<%# Bind("NotAvailalble") %>' > |
<asp:ListItem>Monday</asp:ListItem> |
<asp:ListItem>Tuesday</asp:ListItem> |
</asp:CheckBoxList> |
</EditItemTemplate> |
</telerik:GridTemplateColumn> |