Hi,
I have the following grid:
<TELERIK:RADGRID ID="RadGridProductCharacteristics" runat="server" AutoGenerateColumns="false" AllowAutomaticUpdates="true" OnItemUpdated="RadGridProductCharacteristics_ItemUpdated" OnItemDataBound="RadGridProductCharacteristics_ItemDataBound" OnItemCommand="RadGridProductCharacteristics_ItemCommand" OnPreRender="RadGridProductCharacteristics_PreRender">
<CLIENTSETTINGS AllowGroupExpandCollapse="true" />
<MASTERTABLEVIEW DataKeyNames="CharacteristicID" GroupLoadMode="Client" CommandItemDisplay="Top" EditMode="Batch">
<BATCHEDITINGSETTINGS EditType="Cell" />
<GROUPBYEXPRESSIONS>
<TELERIK:GRIDGROUPBYEXPRESSION>
<GROUPBYFIELDS>
<TELERIK:GRIDGROUPBYFIELD FieldName="ParentCharacteristicName" />
</GROUPBYFIELDS>
<SELECTFIELDS>
<TELERIK:GRIDGROUPBYFIELD FieldName="ParentCharacteristicName" HeaderText="Parent Characteristic" />
</SELECTFIELDS>
</TELERIK:GRIDGROUPBYEXPRESSION>
</GROUPBYEXPRESSIONS>
<COLUMNS>
<TELERIK:GRIDBOUNDCOLUMN HeaderText="Characteristic" DataField="CharacteristicName" ReadOnly="true" />
<TELERIK:GRIDBOUNDCOLUMN UniqueName="CharacteristicValue" HeaderText="Value" DataField="CharacteristicValue" />
<TELERIK:GRIDTEMPLATECOLUMN HeaderText="Color" UniqueName="CharacteristicColor" DataField="CharacteristicColor">
<ITEMTEMPLATE>
<%# Eval("CharacteristicColor") %>
</ITEMTEMPLATE>
<EDITITEMTEMPLATE>
<TELERIK:RADDROPDOWNLIST runat="server" ID="RadDropDownListColor" />
</EDITITEMTEMPLATE>
</TELERIK:GRIDTEMPLATECOLUMN>
<TELERIK:GRIDBUTTONCOLUMN UniqueName="ImageButtonDelete" HeaderText="Action" ButtonType="ImageButton" ImageUrl="~/Resources/Images/icon_delete.png" CommandName="Delete" />
</COLUMNS>
</MASTERTABLEVIEW>
</TELERIK:RADGRID>
I would like to fill the RadDropDownListColor so it is filled when the user clicks the cell to edit the value.
I checked this article: Column Editors and from there I derived the following code:
protected void RadGridProductCharacteristics_PreRender(object sender, EventArgs e)
{
GridTableView masterTable = (sender as RadGrid).MasterTableView;
RadDropDownList radDropDownListColor = masterTable.GetBatchColumnEditor("CharacteristicColor") as RadDropDownList;
radDropDownListColor.DataSource = DBCom.GetHTMLColors();
radDropDownListColor.DataTextField = "HTMLColorName";
radDropDownListColor.DataValueField = "HTMLColorCode";
radDropDownListColor.DataBind();
radDropDownListColor.Items.Insert(0, new DropDownListItem("", "0"));
}
But still the variable radDropDownListColor is null.
What am I doing wrong?