I am trying to fill and edit Checkboxlist with values as in the datagrid i combine all those values into one field to show better, long story. Anyway i need to first populate all teh avialable checkbox list items to choose from, got this done but next I need to hit the database and get the checkboxlist items that are checked already and populate that. So far unsuccessfull.
Protected Sub myRadGrid_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles myRadGrid.ItemDataBound If TypeOf e.Item Is GridEditableItem And e.Item.IsInEditMode Then Dim Item As GridEditableItem = CType(e.Item, GridEditableItem) Dim cbl As CheckBoxList = Item.FindControl("cblReg") Dim Id As Integer = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("intCategoryId") 'populate the checkboxlist will all avialable items sql = "Select COLUMN_NAME from ITSystems.INFORMATION_SCHEMA.COLUMNS where Table_name = 'Drat_Registration' and COLUMN_NAME not like 'int%'" myDataTable = New DataTable myDataTable = getData(sql) cbl.DataSource = myDataTable cbl.DataTextField = "COLUMN_NAME" cbl.DataValueField = "COLUMN_NAME" cbl.DataBind() 'get the existing items that should be checked when editing sql = "Select strFieldName from Drat_regRelation where intCategoryId = " & Id myDataTable = New DataTable myDataTable = getData(sql) For Each row As DataRow In myDataTable.Rows For Each Item In cbl.Items If row(0) = cbl.DataValueField Then cbl.SelectedValue = True End If Next Next End If End Sub
<telerik:RadGrid ID="myRadGrid" runat="server" Width="100%" BorderWidth="1px" CellPadding="6" GridLines="None" BorderColor="#404040" Skin="Web20">
<MasterTableView AutoGenerateColumns="false" DataKeyNames="Category" Name="MasterGrid" BorderColor="#404040" Font-Size="9" Font-Names="Veranda,arial,sans-serif"
HeaderStyle-HorizontalAlign="Center" GridLines="Both" BorderWidth="1px"><AlternatingItemStyle BackColor="#B0C4DE" />
<HeaderStyle ForeColor="White" Font-Bold="true" BorderColor="#404040" BorderWidth="1px" />
<Columns>
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn"></telerik:GridEditCommandColumn>
<telerik:GridBoundColumn DataField="Category" HeaderText="Category" />
<telerik:GridBoundColumn DataField="DataFields" HeaderText="REG DATA" />
</Columns>
<EditFormSettings EditFormType="Template">
<FormTemplate>
<table width="100%">
<tr>
<td style="height:8px"></td>
</tr>
<tr>
<td><b>EDIT DETAILS</b></td>
</tr>
</table>
<table width="100%">
<tr>
<td align="left"><asp:CheckBoxList ID="cblReg" runat="server" DataTextField="strCategory" DataValueField="intCategoryId"></asp:CheckBoxList></td>
</tr>
<tr>
<td style="height:5px"></td>
</tr>
</table>
<table width="100%">
<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>
<tr>
<td style="height:8px"></td>
</tr>
</table>
</FormTemplate>
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>