【发布时间】:2011-08-08 11:39:01
【问题描述】:
我在这里发布这个问题,因为这件事实际上在过去的几周里让我很头疼。我把它放了一段时间,但如果可以的话,我真的会使用那个工具。
我总是在下拉菜单中看到通用错误 500。
这是服务的代码:
using System;
using System.Web;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Web.Services;
using System.Web.Services.Protocols;
using AjaxControlToolkit;
using System.Data;
using System.Data.SqlClient;
/// <summary>
/// Summary description for inputHoursWS
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX,
//uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class inputHoursWS : System.Web.Services.WebService {
public inputHoursWS () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public CascadingDropDownNameValue[] getGroupCodes(string knownCategoryValues,
string Category)
{
InputHoursDSTableAdapters.TMS_ProjectGroupsTableAdapter projectGroupTA = new InputHoursDSTableAdapters.TMS_ProjectGroupsTableAdapter();
InputHoursDS.TMS_ProjectGroupsDataTable groups = projectGroupTA.GetProjectGroups();
List<CascadingDropDownNameValue> groupValues = new List<CascadingDropDownNameValue>();
foreach (DataRow row in groups)
{
int groupId = (int)row["ProjectGroupID"];
string groupCode = (string)row["ProjectGroup"];
groupValues.Add(new CascadingDropDownNameValue(groupCode, groupId.ToString()));
}
return groupValues.ToArray();
}
}
这是前端网页表单的代码:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:DropDownList ID="ddlGroups" runat="server" Width="70px" Height="21px">
</asp:DropDownList>
<asp:CascadingDropDown ID="ddlGroups_CascadingDropDown"
runat="server"
TargetControlID="ddlGroups"
Category="ProjectGroup"
PromptText="Choose a Group"
LoadingText="Please wait ..."
ServicePath="inputHoursWS.asmx"
ServiceMethod="getGroupCodes">
</asp:CascadingDropDown>
InputHoursDS 数据集中的方法工作正常。我正在远程访问开发机器。安装了 Visual Web Developer 2010,并且 IIS 6 正在运行 .NET 4.0
还有一个相关的快速问题 - 您在前端的“Category”属性中添加了什么值?它是来自数据库标题还是您自己的标题?
【问题讨论】: