一千萬個為什麽

搜索

在Ajax Control Toolkit中的級聯下拉更新中

當我使用級聯下拉時,我得到[MethodError 500]。下面是我的代碼

    <tr>
<td >
Select a Hoster: 
</td>
<td>

 </td>
 </tr>



服務代碼:

 [WebMethod]
    [ScriptMethod]
    public CascadingDropDownNameValue[] GetActiveHosters()
    {

        List returnList = new List();
        HostersManager hosterManager = new HostersManager();
        List hosters = hosterManager.GetAllHosters();
        returnList.Add(new CascadingDropDownNameValue("--Please Select One--","0",true));
        foreach (Hosters_HostingProviderDetail item in hosters)
        {
            returnList.Add(new CascadingDropDownNameValue() {  name=item.HostingProviderName, value= item.HosterID.ToString()});
        }
        return returnList.ToArray() ;
    }
  [WebMethod]
    [ScriptMethod]
    public CascadingDropDownNameValue[] GetDropDownContents(string knownCategoryValues, string category)
    {
        knownCategoryValues = FormatCategoryWord(knownCategoryValues);
        List values = new List();
        HostersManager hosterManager = new HostersManager();
        switch (category)
        {
            case "ActiveHoster":
                values.AddRange(GetActiveHosters());
                break;
            case "ActiveOffer":
                values.AddRange(GetActiveOffers(1));
                break;
        }
        return values.ToArray();

    }

    /// 
/// Formats the category word ///
 
    /// 
    /// 
    private string FormatCategoryWord(string value)
    {
        if (string.IsNullOrEmpty(value)) return value;
        if (value.LastIndexOf(":") > 0) value = value.Substring(value.LastIndexOf(":") + 1);
        if (value.LastIndexOf(";") > 0) value = value.Substring(0, value.LastIndexOf(";"));
        return value;
    }

}

最佳答案

如何通過一些異常記錄嘗試在webMethods中捕獲塊?

轉載註明原文: 在Ajax Control Toolkit中的級聯下拉更新中