Changing GridDropDownColumn value depending upon value of other GridDropDownColumn value change

Thread is closed for posting
3 posts, 0 answers
  1. Jijumon K G
    Jijumon K G avatar
    2 posts
    Member since:
    Aug 2009

    Posted 19 Mar 2013 Link to this post

    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. Jijumon K G
    Jijumon K G avatar
    2 posts
    Member since:
    Aug 2009

    Posted 19 Mar 2013 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Angel Petrov
    Admin
    Angel Petrov avatar
    1007 posts

    Posted 22 Mar 2013 Link to this post

    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.
Back to Top