【发布时间】:2014-04-18 14:27:33
【问题描述】:
` 公共部分类 DropDownApi : System.Web.UI.Page { string _URL = "/api/Insurance";
protected void Page_Load(object sender, EventArgs e)
{
WebRequest req = WebRequest.Create(_URL);
req.Method = "GET";
// req.Headers.Add("key");
req.ContentType = "application/json; charset=utf-8";
WebResponse resp = req.GetResponse();
Stream stream = resp.GetResponseStream();
StreamReader re = new StreamReader(stream);
String json = re.ReadToEnd();
json = "{\"InsuranceDetails\":" + json + "}";
wrapper w = (wrapper)new JavaScriptSerializer().Deserialize(json, typeof(wrapper));
ddlinsurance.DataSource = w.InsuranceDetails;
ddlinsurance.DataBind();
}
public class wrapper
{
public List<insurance_master> InsuranceDetails { get; set; }
}`<asp:DropDownList ID="ddlinsurance" runat="server" AutoPostBack="false" DataTextField="policy_number"></asp:DropDownList>`
`我有一个包含 json 数据(policy_number)的下拉列表,现在当我从下拉列表中选择 policy_number 时,它必须通过匹配选定的 policy_number 在文本框中显示剩余的详细信息。我已经为我的项目使用了 MVC WebApi 服务。 谁能帮帮我!!!
提前致谢。
【问题讨论】:
-
告诉我们你做了什么
-
请包含您目前编写的代码,并告诉我们您遇到的问题。无论如何,您都需要研究如何解决这个问题。在互联网上搜索这篇文章的标题无疑会让你上路。
标签: c# asp.net json asp.net-web-api