System.Web.UI.HtmlControls.HtmlTable t = new System.Web.UI.HtmlControls.HtmlTable(); System.Web.UI.HtmlControls.HtmlTableRow row = new System.Web.UI.HtmlControls.HtmlTableRow(); System.Web.UI.HtmlControls.HtmlTableCell cell = new System.Web.UI.HtmlControls.HtmlTableCell(); row.Controls.Add(cell); t.Controls.Add(row); 类似这样,自己拼吧
Literal li = new Literal(); li.Text = "<div>><ul><li>1111111</li><li>222222</li><li>333333</li><li>4444444</li></ul></div>"; this.Page.Controls.Add(li);
<asp:Panel ID="Panel" runat="server"></asp:Panel> String connStr = ConfigurationManager.AppSettings["SQLConn"]; String sql = "select * from table_name"; DataTable dt = new DataTable(); using (SqlConnection conn = new SqlConnection(connStr)) { conn.Open(); SqlCommand sd = new SqlCommand(sql, conn); SqlDataAdapter sa = new SqlDataAdapter(sd); sa.Fill(dt); } HtmlTable table = new HtmlTable(); foreach(DataRow dr in dt) { HtmlTableRow row = new HtmlTableRow(); HtmlTableCell cell1 = new HtmlTableCell(); HtmlTableCell cell2 = new HtmlTableCell(); HtmlTableCell cell3 = new HtmlTableCell(); cell1.InnerHtml = dr["列名"].ToString(); cell1.InnerHtml = dr["列名"].ToString(); cell1.InnerHtml = "<img src='"+dr["列名"].ToString()+"'/>";//图片 row.Cells.Add(cell1); row.Cells.Add(cell2); row.Cells.Add(cell3); table.Rows.Add(row); } this.Panel.Controls.Add(table);
myconn.Open(); SqlDataReader dr = da.ExecuteReader(); Response.Write("<table border=1px;"); while (dr.Read()) {
<headtemplate>
<table>
<tr><td></td></tr>
</headtemplate>
<itemtemplate>
<tr><td><%#Eval("img")%></td></tr>
</itemtemplate>
<foottemplate>
</table>
</foottemplate>
</asp:repeater>
System.Web.UI.HtmlControls.HtmlTable t = new System.Web.UI.HtmlControls.HtmlTable();
System.Web.UI.HtmlControls.HtmlTableRow row = new System.Web.UI.HtmlControls.HtmlTableRow();
System.Web.UI.HtmlControls.HtmlTableCell cell = new System.Web.UI.HtmlControls.HtmlTableCell();
row.Controls.Add(cell);
t.Controls.Add(row);
类似这样,自己拼吧
sb.append(@"<table>
<tr> <td> </td> </tr>");
foreach(datarow dr in ds.tables[0].rows)
{
sb.append(@"<tr> <td>" + dr["xxx"] + "</td> </tr>");}
sb.append("</table>");
<div id='divID'/>//.csstring str="<table>";for( , , )
{
str+="<tr><td>...</td>.....</tr>";//构造你要的table
}
str+"</table>";
div.innerHTML=str;
li.Text = "<div>><ul><li>1111111</li><li>222222</li><li>333333</li><li>4444444</li></ul></div>";
this.Page.Controls.Add(li);
String sql = "select * from table_name";
DataTable dt = new DataTable(); using (SqlConnection conn = new SqlConnection(connStr))
{
conn.Open();
SqlCommand sd = new SqlCommand(sql, conn);
SqlDataAdapter sa = new SqlDataAdapter(sd);
sa.Fill(dt);
} HtmlTable table = new HtmlTable(); foreach(DataRow dr in dt)
{
HtmlTableRow row = new HtmlTableRow(); HtmlTableCell cell1 = new HtmlTableCell();
HtmlTableCell cell2 = new HtmlTableCell();
HtmlTableCell cell3 = new HtmlTableCell(); cell1.InnerHtml = dr["列名"].ToString();
cell1.InnerHtml = dr["列名"].ToString();
cell1.InnerHtml = "<img src='"+dr["列名"].ToString()+"'/>";//图片 row.Cells.Add(cell1);
row.Cells.Add(cell2);
row.Cells.Add(cell3); table.Rows.Add(row);
} this.Panel.Controls.Add(table);
SqlDataReader dr = da.ExecuteReader();
Response.Write("<table border=1px;");
while (dr.Read())
{
Response.Write("<tr><td>"+dr.GetValue(1).ToString()+"</td>");
Response.Write("<td>"+dr.GetValue(2).ToString()+"</td></tr>"); }
Response.Write("</table>");
myconn.Close();
dr.Close();