I am using RadGrid in my asp.net project. When I click on Add new Record link, new row in RadGrid gets added. This new row contains four RadComboBox controls.When I select any particular value in first RadComboBox, respective value should be autopopulated in other three RadComboBox controls of new row. How can I achieve for new row in RadGrid..
Appreciate if you could help, Thanks!
7 Answers, 1 is accepted
I tried the scenario by using FormTemplate with four RadComboBoxes. In the SelectedIndexChanged event of the first RadComboBox, set the selectedvalue of other RadComboBoxes.
Here's the ASPX:
You can also refer the links which describes about Multiple ComboBoxes
Thanks for your reply. I need to use this 4 radcombobox under radgrid. So FormTemplate will work in this case?
From your first post, I assumed that the comboboxes were placed in the EditForm of the grid. But from your last post- I suppose you have the comboboxes outside the grid as you have mentioned "I need to use this 4 radcombobox under radgrid". For either of these cases you can populate the RadComboBoxes same logic of setting the selected values of the other three combo boxes when the first combo's selection is changed:
Could you share your RadGrid declaration along with the code-behind file? Thus everyone that want to help you will have better understanding of your project.
the Telerik team
protected void grdTestTool_ItemCreated(object sender, GridItemEventArgs e)
if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
GridEditFormItem editFormItem = e.Item as GridEditFormItem;
RadComboBox automationToolComboBox = editFormItem.FindControl("cmbTestTool") as RadComboBox;
automationToolComboBox.SelectedIndexChanged += cmbTestTool_SelectedIndexChanged;
But I found the solution, it was my fault of not using the grid's NeedDataSource event to bind the grid.
I used to bind the grid for every postback in the page load, to sustain the grid between postback
with statements :
So even an item selection from combobox, which raised the postback used to rebind the grid due to the code in the pageload.
and so my combobox's selectedindexchanged event was not raised.
But I got to know now that handling NeedDataSource Event of grid, would handle postback binding by itself, avoiding the need to bind in the pageload, also NeedDataSource Event would not rebind the grid on selecting the combobox, thus raising the selectedIndexchanged event of combobox.
void grdTestTool_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
List<string> someList = SessionHelper.GetList(Session);
grdTestTools.DataSource = someList
Yes, you are absolutely correct, when FormTemplate is used the simple databinding mechanism is not supported and since you are rebinding the grid on every Page_Load the event information is lost on postback.
More about the NeedDataSource event could be found in this help topic.
All the best,
the Telerik team