如题

解决方案 »

  1.   

    literal.Text = "<table><tr><td>content</td></tr></table>";
      

  2.   

    //拼接字符串(保险记录)
                string safeTable = "<table width='100%' bgcolor='#ffffff' border='1' cellspacing='0' cellpadding='0' style='text-align:center;'>";
                safeTable += "<tr bgcolor='#074f7f' style='height:30px;'><td width='15%'>时间</td>";
                safeTable += "<td width='4%'>类型</td>";
                safeTable += "<td width='5%'>经手人</td>";
                safeTable += "<td width='25%'>备注</td>";
                safeTable += "</tr>";
     foreach (DataRow row in dtRecord.Rows)
                {
                    if (row["recordSafe"] != null && !row["recordSafe"].ToString().Equals(""))
                    { 
                        string[] safe = row["recordSafe"].ToString().Split(',');
                        //拼接字符串(保险记录)
                        safeTable += "<tr style='height:25px;'>";
                        safeTable += "<td width='10%'>" + safe[0] + "</td>";
                        safeTable += "<td width='4%'>" + safe[1] + "</td>";
                        safeTable += "<td width='5%'>" + safe[2] + "</td>";
                        safeTable += "<td width='25%'>" + safe[3] + "</td>";
                        safeTable += "</tr>";
                    }
                } litSafe.Text = safeTable;
    然后前台这样写:
    <asp:Literal ID="litSafe" runat="server"></asp:Literal>