首页 > Web开发 > 详细

json

时间:2017-09-05 09:25:08      阅读:251      评论:0      收藏:0      [点我收藏+]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Text;
using System.Web.Script.Serialization;

namespace FireNews
{
/// <summary>
/// $codebehindclassname$ 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class GetRoportList : IHttpHandler
{
DAL.SelfCheckInfo dal_info = new DAL.SelfCheckInfo();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
//context.Response.Write("Hello World");
if (!string.IsNullOrEmpty(context.Request.QueryString["UnitType"]))
{
string type = context.Request.QueryString["UnitType"].ToString().Trim();//传过来参数的名字 我这里使用的是get方式
DataTable dt = dal_info.GetList("type like ‘%"+type+"%‘").Tables[0];//这里改成你需要的sql语句
List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
if (dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
Dictionary<string, object> result = new Dictionary<string, object>();
foreach (DataColumn dc in dt.Columns)
{
result.Add(dc.ColumnName, dr[dc].ToString());
}
list.Add(result);
}
context.Response.Write(new JavaScriptSerializer().Serialize(list));
}
}
}

public bool IsReusable
{
get
{
return false;
}
}
}
}

json

原文:http://www.cnblogs.com/ljsjxr/p/7476759.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!