使用Ajax级联下拉列表

时间:2014-04-17 21:56:39

标签: c# ajax telerik radgrid

我是Ajax的新手。我正在telerik RadGrid中实现级联下拉列表。 我正在添加dropdownList和CascadingDropDown,如下所示:

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

在PreRender上我有以下内容:     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);         
   }

在ajaxservice.asmx中我有以下内容:

  [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();
  }        

第一个dropDown,DropDownListOrderTask不包含任何值。在通过Firebug进行调试时,它说:ReferenceError:未定义BindOrderTask 我确信我错过了一些东西,但不确定是什么。请帮帮我。

0 个答案:

没有答案