日期:2014-05-18  浏览次数:20387 次

有数据但是不显示
C# code

  </tr>
         <%DAO.PageHelp ph = ViewData["ph"] as DAO.PageHelp;
          if(ph!= null){
           foreach (Dictionary<string, object> dics in ph.PageData)
          {
              double num = Convert.ToInt32(dics["InTimeCount"].ToString())/Convert.ToInt32(dics["EventAll"].ToString());
          %>
         <tr>
            <td><%=dics["UIC"]%></td>
            <td><%=dics["UName"]%></td>
            <td><%=dics["EventAll"]%></td>
            <td><%=dics["InTimeCount"]%></td>
            <td><%=dics["OutTimeCount"]%></td>
            <td><%=num.ToString("p")%></td>
        </tr>
       <%} %>
       <%} %>

ViewData["ph"]里面有值的我跟踪断点可以看到,就是不只为什么页面中显示出来的总是空白,但是我导出数据却是有的。



------解决方案--------------------
去asp板块
------解决方案--------------------
我这样写是可以显示的
HTML code

<div>
        <table>
            <tr>
                <td>
                    1
                </td>
            </tr>
            <% System.Collections.Generic.Dictionary<string, object> dic = new System.Collections.Generic.Dictionary<string, object>();

               dic.Add("1", "100");
               dic.Add("2", "2");
               dic.Add("3", "3");
               dic.Add("4", "4");
               System.Collections.Generic.List<System.Collections.Generic.Dictionary<string, object>> ph = new System.Collections.Generic.List<System.Collections.Generic.Dictionary<string, object>>();
               ph.Add(dic);
               if (ph != null)
               {
                   foreach (System.Collections.Generic.Dictionary<string,object> dics in ph)
                   {
                       double num = Convert.ToInt32(dics["1"].ToString()) / Convert.ToInt32(dics["3"].ToString());
            %>
            <tr>
                <td>
                    <%=dics["1"]%>
                </td>
                <td>
                    <%=dics["2"]%>
                </td>
                <td>
                    <%=dics["3"]%>
                </td>
                <td>
                    <%=dics["4"]%>
                </td>
                <td>
                    <%=num.ToString("p")%>
                </td>
            </tr>
            <%} %>
            <%} %>
        </table>
    </div>