Fill RadDropDownList in Grid with BatchEdit Mode

1 Answer 87 Views
DropDownList Grid
Top achievements
Rank 1
Bart asked on 27 Mar 2023, 12:51 PM


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">
					<TELERIK:GRIDGROUPBYFIELD FieldName="ParentCharacteristicName" />
					<TELERIK:GRIDGROUPBYFIELD FieldName="ParentCharacteristicName" HeaderText="Parent Characteristic" />
			<TELERIK:GRIDBOUNDCOLUMN HeaderText="Characteristic" DataField="CharacteristicName" ReadOnly="true" />
			<TELERIK:GRIDBOUNDCOLUMN UniqueName="CharacteristicValue" HeaderText="Value" DataField="CharacteristicValue" />
			<TELERIK:GRIDTEMPLATECOLUMN HeaderText="Color" UniqueName="CharacteristicColor" DataField="CharacteristicColor">
					<%# Eval("CharacteristicColor") %>
					<TELERIK:RADDROPDOWNLIST runat="server" ID="RadDropDownListColor" />
			<TELERIK:GRIDBUTTONCOLUMN UniqueName="ImageButtonDelete" HeaderText="Action" ButtonType="ImageButton" ImageUrl="~/Resources/Images/icon_delete.png" CommandName="Delete" />

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.Items.Insert(0, new DropDownListItem("", "0"));

But still the variable radDropDownListColor is null.

What am I doing wrong?

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 30 Mar 2023, 10:35 AM


The BatchEdit is a Client-Side (JavaScript-based) functionality of the Grid, therefore, interaction with the Grid must be done on the Client-Side. Normally using TemplateColumns is not recommended when using BatchEditing but it can be used for simple Templates. Such scenarios however need manual handling of the editing.

The following article describes the main aspects of Batch Editing: RadGrid Batch Editing Templates and Specifics.
The specifics when using templates in Batch editing are explained in the Working With Templates article.
In this case, you should use the Client-Side APIs of both the Grid and the DropDownList to set the values of the cell and editor. The following client-side events can be used for the purpose:

You can find sample implementation using these events in the Working With Templates article linked above. 

I hope this information will help you achieve the desired. Please let me know if any further questions come up.

Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

DropDownList Grid
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question