Click here to Skip to main content
16,016,580 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I want to implement cascading dropdownlist in a telerik Radgrid. On click of Insert, the dropdowns should appear.According to selection in the first dropdown, the second will be poopulated after an Ajax call. I want it to be client side and have failed to find good examples. Please help.

Inside the radgrid, I am creating dropdowns as follows:

protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
      {
 
          if (e.Item is GridEditableItem && e.Item.IsInEditMode)
          {
              GridEditableItem item = e.Item as GridEditableItem;
              GridEditManager manager = item.EditManager;
 
              HyperLink hyperLink = (HyperLink)item["OrderTask"].Controls[0];
              hyperLink.Visible = false;
 
              DropDownList droplist = new DropDownList();
 
              droplist.ID = "DropDownListOrderTask";
              droplist.AutoPostBack = true;         
              item["OrderTask"].Controls.Add(droplist);
              CascadingDropDown ccdOrderTask = new CascadingDropDown();
              ccdOrderTask.ID = "ccdOrderTask";
              ccdOrderTask.Category = "OrderTask";
              ccdOrderTask.TargetControlID = "DropDownListOrderTask";
              ccdOrderTask.PromptText = "Select Order Task";
              ccdOrderTask.LoadingText = "Loading OrderTask";
              ccdOrderTask.ServiceMethod = "BindOrderTask";
              ccdOrderTask.ServicePath = "ajaxservice.asmx";                            
                 
              TextBox txt = (TextBox)item["TaskOwner"].Controls[0];
              txt.Visible = false;
              droplist = new DropDownList();
              droplist.ID = "DropDownListTaskOwner";
              item["TaskOwner"].Controls.Add(droplist);
              CascadingDropDown ccdTaskOwner = new CascadingDropDown();
              ccdTaskOwner.ID = "ccdTaskOwner";
              ccdTaskOwner.Category = "TaskOwner";
              ccdTaskOwner.ParentControlID = "DropDownListOrderTask";
              ccdTaskOwner.TargetControlID = "DropDownListTaskOwner";
              ccdTaskOwner.PromptText = "Select Task Owner";
              ccdTaskOwner.LoadingText = "Loading Task Owner";
              ccdTaskOwner.ServiceMethod = "BindTaskOwner";
              ccdTaskOwner.ServicePath = "ajaxservice.asmx"; 
          }
      }


But the cascading dropdown list does not call the method!BindOrdertask method is as follows:

[WebMethod]
      public CascadingDropDownNameValue[] BindOrderTask(string knownCategoryValues, string category)
      {
          OrderRequestTaskTypeTable _orderRequestTaskTypeTable = new OrderRequestTaskType_List().ExecuteTypedDataTable();
          List<CascadingDropDownNameValue> orderTaskDetails = new List<CascadingDropDownNameValue>();
          foreach(DataRow dtRow in _orderRequestTaskTypeTable.Rows)
          {
                 String orderTaskId = dtRow["OrderRequestTaskTypeId"].ToString();
                 String orderTaskName = dtRow["DescriptionTaskType"].ToString();
                  //orderTaskDetails.Add(new CascadingDropDownNameValue(orderTaskId, orderTaskName));
                 orderTaskDetails.Add(new CascadingDropDownNameValue("orderTaskId", "orderTaskName"));
           }
            return orderTaskDetails.ToArray();
      }           
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900