zoukankan      html  css  js  c++  java
  • MVC中ViewData中数据转化成json形式的变量的方法

         public ActionResult DataQuery()
            {          
                using (var query = new QueryBLL.QueryClient())
                {
                    var x = query.DataQuery(userid);
                    var parent =
                        (from a in x.Values select (new { parentid = a.ResourceType.Name, parentname = a.ResourceType.DisPlayName }))
                            .Distinct().ToList();
                    var child = (from b in x.Values
                                 select (new { parentid = b.ResourceType.Name, childid = b.Name, childname = b.DisPlayName })).ToList();
                    ViewData["parent"] = CHINAZTT.ZTAM.UI.Controllers.common.toJSON(parent, "data");
                    ViewData["child"] = CHINAZTT.ZTAM.UI.Controllers.common.toJSON(child, "data");
                }

                return View();
            }

    <asp:Content ID="Content2" ContentPlaceHolderID="Header" runat="server">
        <%if (ViewData["parent"] == null || (ViewData["parent"].ToString().Length < 5))
              return;
          else
          {
              Response.Write(@"<script type=""text/javascript"">");
              Response.Write(" var parent=" + ViewData["parent"] + ";");
              Response.Write(" var child=" + ViewData["child"] + ";");
              Response.Write("</script>");
          }
        %>
        <style type="text/css">
            .style2
            {
                height: 22px;
            }
        </style>
    </asp:Content>

  • 相关阅读:
    计算机硬件知识整理
    cf689d ST表RMQ+二分
    hdu5289 ST表+二分
    hdu5443 ST表裸题:求区间最大
    poj3264 倍增法(ST表)裸题
    cf932d 树上倍增
    zoj3195 联通树上三个点的路径长
    hdu6107 倍增法st表
    hdu2586 lca倍增法
    poj1470 LCA倍增法
  • 原文地址:https://www.cnblogs.com/QiuJL/p/4524239.html
Copyright © 2011-2022 走看看