ios请求 返回json数据


1 返回json格式的数据
2:json 格式:[{1},{2}{3},{4},{5},{6}]

using System.Web.Script.Serialization;    //命名空间


public partial class index : System.Web.UI.Page
    {
        BLL.events bll_event = new Maticsoft.BLL.events();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadEts();
            }
        }


        protected void LoadEts()
        {
            string conditoin="";
            string topnum = "";
            if (Request.QueryString["title"] !=null)
            {
                conditoin = " where classname = '"+ Request.QueryString["title"].ToString().Trim()+"'";
            }
            if (Request.QueryString["count"] != null)
            {
                topnum = " top " + topnum;
            }
            JavaScriptSerializer json = new JavaScriptSerializer();
            DataTable ds_event = bll_event.getEventBySomeWhere(topnum,conditoin);
            if (ds_event.Rows.Count > 0)
            {
                string str = string.Empty;
                for (int i = 0; i < ds_event.Rows.Count; i++)
                {
                    DataRow dr=ds_event.Rows[i];
                    Model.events oneevent = new Maticsoft.Model.events();
                    oneevent.id =int.Parse(dr["id"].ToString());
                    oneevent.title = dr["title"].ToString();
                    oneevent.username=dr["username"].ToString();
                    oneevent.pic=dr["pic"].ToString();
                    oneevent.address = dr["address"].ToString();
                    oneevent.cityaddress = dr["cityaddress"].ToString();
                    oneevent.starttime =DateTime.Parse(dr["starttime"].ToString());
                    oneevent.endtime =DateTime.Parse(dr["endtime"].ToString());
                    oneevent.contents = dr["contents"].ToString();
                    oneevent.classname = dr["classname"].ToString();
                    oneevent.seecount =int.Parse(dr["seecount"].ToString());
                    oneevent.joincount =int.Parse(dr["joincount"].ToString());
                    oneevent.jionmoney = dr["jionmoney"].ToString();
                    oneevent.personcount =int.Parse(dr["personcount"].ToString());
                    oneevent.tudu = dr["tudu"].ToString();
                    oneevent.viewcount =int.Parse(dr["viewcount"].ToString());
                    str  =str+"<br/>"+ json.Serialize(oneevent);//对象数据 变为json格式                                                       数据
                }
                //this.Literal1.Text = str.ToString(); //赋值给控件显示
                Response.Write(str.ToString());  // ios url请求是返回数据 的方式response.write()
                Response.End();
            }

           
        }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值