使用Ajax级联下拉菜单

I am new to Ajax. I am implementing a cascading dropdown in a telerik RadGrid. I am adding the dropdownList and CascadingDropDown as follows:

          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"; 

On the PreRender I have the following: protected override void OnPreRender(EventArgs e) { base.OnPreRender(e);

       var ajaxManager = RadAjaxManager.GetCurrent(Page);

       if(ajaxManager != null)
           ajaxManager.AjaxSettings.AddAjaxSetting(this._UpdatePanel, this._RadGrid1, this._RadLoadingPanel);         
   }

In the ajaxservice.asmx I have the following:

  [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));
     }
    return orderTaskDetails.ToArray();
  }        

The first dropDown, DropDownListOrderTask contains no values. On debugging through Firebug it says: ReferenceError: BindOrderTask is not defined I am sure I am missing something but not sure what. Please help me.

查看全部
weixin_33698823
weixin_33698823
2014/04/17 21:56
  • c#
  • telerik
  • ajax
  • 点赞
  • 收藏
  • 回答
    私信

0个回复