• 未定义对象


    public partial class LayJsonModel
        {
            /// <summary>
            /// 状态
            /// </summary>
            public string code
            {
                get;
                set;
            }
            /// <summary>
            /// 消息
            /// </summary>
            public string msg
            {
                get;
                set;
            }
            public int count
            {
                get;
                set;
            }
            /// <summary>
            /// 数据
            /// </summary>
            public List<dataModel> data
            {
                get;
                set;
            }
     
        }
    View C
      public class dataModel
        {
            public string DocEntry
            {get;
            set;}
            public string taxDate
            {
                get;
                set;
            }
        }
    View Code
    ode
    public void order_v_list(HttpContext context)
        {
            LayJsonModel msgmodel = new LayJsonModel();
    
            try
            {
    
                string message = string.Empty;
    
                string id = context.Request["id"];
    
                string sqlstr = "select docentry,taxdate from orders  where cardname='泉州一范'";
    
                DataTable dt = bdc.GetDataTable(sqlstr);
                StringBuilder JsonSb = new StringBuilder();
    
                if (dt != null && dt.Rows.Count > 0)
                {
                    string jsonString = JsonConvert.SerializeObject(dt);
                    msgmodel.code  = "0";
                    msgmodel.count = 5000;
                    msgmodel.msg = "";
    
                   // JsonSb.Append("[");
                    List<dataModel> dmodel = new List<dataModel>();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        //dataModel dmodels = new dataModel();
                        //dmodels.DocEntry = dt.Rows[i]["DocEntry"].ToString();
                        //dmodels.taxDate = dt.Rows[i]["taxDate"].ToString();
                        //msgmodel.data.Add(dmodels);//这样写会提示未将对象引用到实例
                        dataModel d = new dataModel();
                        d.DocEntry = dt.Rows[i]["DocEntry"].ToString();
                        d.taxDate = dt.Rows[i]["taxDate"].ToString();
                        dmodel.Add(d);
                       
                    }
                    msgmodel.data = dmodel;
                   
                    //string tmp = JsonSb.ToString().Trim(',') + "]";
                    //msgmodel.data = tmp;
                }
    
                string JSONObj = JsonConvert.SerializeObject(msgmodel);
    
    
                context.Response.ContentType = "text/plain";
                context.Response.Write(JSONObj); //返回给前台页面  
            }
            catch (Exception ex)
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write(ex.Message); //返回给前台页面  
                context.Response.End();
            }
        }
    View Code
  • 相关阅读:
    计算机学习—系统优化(1)
    B站Vue教学视频-个人随笔笔记-(031-040)
    B站Vue教学视频-个人随笔笔记-(021-030)
    B站Vue教学视频-个人随笔笔记-(011-020)
    B站Vue教学视频-个人随笔笔记-(001-010)
    Docker入门(三):容器(Containers)
    WinDBG符号路径设置
    Docker入门(二):安装/卸载
    Docker入门(一):简介
    CentOS下安装配置Samba服务器
  • 原文地址:https://www.cnblogs.com/niyl/p/9515984.html
Copyright © 2020-2023  润新知