ASP.NET C#基于Soap服务中特定类别的项目筛选DropDownList

本文关键字:项目 DropDownList 筛选 NET 基于 Soap 服务 ASP | 更新日期: 2023-09-27 18:16:04

好。。。我被困在这里了。有点像C#和消费web服务的新手。我已经成功地从SOAP服务填充了DropDownList,但我真正需要的是根据特定的类别过滤该列表。

到目前为止,我拥有的是:

problemReporting.soapClient s = new problemReporting.soapClient();
problemReporting.NullRequest nr = new NullRequest();
problemReporting.ProblemDescription[] getDescList = s.getProblemDescriptionList(nr);
ddlProblem.DataSource = getDescList;
ddlProblem.DataTextField = "description";
ddlProblem.DataValueField = "code";
ddlProblem.DataBind();

problemReporting.ProblemDescription包含"类别"、"描述"answers"代码"。如何将DataSource设置为等于getDescList,其中category=Category1?(共有4个项目类别。该类别将由用户从上一页中选择一个类别来设置,该值将通过HttpUtility.UrlDecode从URL中提取。(

提前感谢您的帮助。

ASP.NET C#基于Soap服务中特定类别的项目筛选DropDownList

是否有原因不在SQL上执行此操作(如果您正在使用SQL(。如果你做不到,我建议你看看LinQ2Entities。祝你好运

试试这个,你可以在调用Linq后进行过滤,但我建议你更改你的web服务,使用一个参数来过滤结果:

problemReporting.soapClient s = new problemReporting.soapClient();
problemReporting.NullRequest nr = new NullRequest();
problemReporting.ProblemDescription[] getDescList = s.getProblemDescriptionList(nr);
var cats = from desc in getDescList 
  where desc.category == "Category1"
  select desc;
ddlProblem.DataSource = cats;
ddlProblem.DataTextField = "description";
ddlProblem.DataValueField = "code";
ddlProblem.DataBind();