This is a migrated thread and some comments may be shown as answers.

Changing GridDropDownColumn value depending upon value of other GridDropDownColumn value change

2 Answers 139 Views
UI for ASP.NET AJAX in ASP.NET MVC
This is a migrated thread and some comments may be shown as answers.
Jijumon K G
Top achievements
Rank 1
Jijumon K G asked on 19 Mar 2013, 03:39 PM

I have two GridDropDownColumn one is category and other is subcategory. The value of Subcategory should load dynamically when category is selected ie. When Category is changed according to the value of that subcategory is loaded.

 

I tried to created selectedIndexChange event for category but inside that I am not able get the control Subcategory. The control is not Template column then I can find the control and it is not possible to create GridTemplateColumn.

Please help me how I can load value depending on the value other GridDropDownColumn.

2 Answers, 1 is accepted

Sort by
0
Jijumon K G
Top achievements
Rank 1
answered on 19 Mar 2013, 06:07 PM
We can get the controls from the radgrid itself.
 Below is the code snippet which help to get the each column and through that we can the control.

 foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns)
        {
            if ((col.UniqueName == "Benefit_SubCategory") && (col.ColumnType == "GridDropDownColumn"))
            {               
                GridDropDownColumn DropCol = (GridDropDownColumn)col;
                RadComboBox BenSubCat = (RadComboBox)DropCol.ColumnEditor.ContainerControl.Controls[0];
                DataAccess objDataAccess = new DataAccess();
                DataTable objDtSubCat = objDataAccess.GetSubCategoryByCatID(e.Text);
                if (objDtSubCat.Rows.Count > 0)
                {
                    BenSubCat.DataSource = objDtSubCat;
                    BenSubCat.DataValueField = "value";
                    BenSubCat.DataTextField = "value";
                    BenSubCat.DataBind();
                    BenSubCat.Items.Insert(0, new RadComboBoxItem("-- Select Option --"));
                }
            }
        }
This may help some one like me. Thanks
0
Angel Petrov
Telerik team
answered on 22 Mar 2013, 03:24 PM
Hi Jijumon,

The functionality desired is hard to achieve using GridDropDownColumn I suggest that you use GridTemplateColumns instead and inside them place the RadComboBoxes. Thus you should be able to use the SelectedInexChanged event of the combo. However if you still want to use GridDropDownColumn you should store somewhere the CliendID of the combo in the second GridDropDownColumn and attach an event handler for the client-side SelectedInexChanged of the combo in the first GridDropDownColumn. Later using JavaScript you can change the value in the desired drop down. This is demonstrated in the project attached.

All the best,
Angel Petrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
UI for ASP.NET AJAX in ASP.NET MVC
Asked by
Jijumon K G
Top achievements
Rank 1
Answers by
Jijumon K G
Top achievements
Rank 1
Angel Petrov
Telerik team
Share this question
or