码迷,mamicode.com
首页 > Web开发 > 详细

json

时间:2017-09-05 09:55:54      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:forms   profile   cprofile   public   .text   summary   col   obj   sys   

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

标签:forms   profile   cprofile   public   .text   summary   col   obj   sys   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!