问:如何动态生成这种形式的表格
统计
_________________________
行业__|行业分类____|数量_|
保安 |公安________|2____| 数据库中(行业分类)=公安有2条记录,这2条记录的行业字段=保安
|武警________|3____|
|警察________|2____|
______|合计________|7____|
变电 |变电________|2____|
|变电站______|3____|
______|合计________|5____|
.
.
其中:行业是数据库中的UsrType字段,行业分类为UsrSubType参考:
string connstr=System.Configuration.ConfigurationSettings.AppSettings["sqllink"];
SqlConnection conn=new SqlConnection(connstr);
conn.Open();
string sql="select UsrType,UsrSubType from view_usract";
SqlCommand cmd=new SqlCommand(sql,conn);
SqlDataReader dr=cmd.ExecuteReader();
this.Response.Write("<table align='center' border='1'>");
this.Response.Write("<tr>");
this.Response.Write("<td align='left'>");
this.Response.Write("用户行业");
this.Response.Write("</td>");
this.Response.Write("<td align='left'>");
this.Response.Write("行业分类");
this.Response.Write("</td>");
this.Response.Write("<td align='left'>");
this.Response.Write("用户数量");
this.Response.Write("</td>");
this.Response.Write("</tr>");
while(dr.Read())
{
this.Response.Write("<tr>");
this.Response.Write("<td align='left'>");
this.Response.Write(dr["UsrType"].ToString());
this.Response.Write("</td>");
this.Response.Write("<td align='left'>");
this.Response.Write(dr1["UsrSubType"].ToString());
this.Response.Write("</td>");
this.Response.Write("<td align='left'>");
this.Response.Write(dr1["UsrSubType"].ToString());
this.Response.Write("</td>");
this.Response.Write("</tr>");
}
this.Response.Write("</table>");
conn.Close();
--blackhero--
统计
_________________________
行业__|行业分类____|数量_|
保安 |公安________|2____| 数据库中(行业分类)=公安有2条记录,这2条记录的行业字段=保安
|武警________|3____|
|警察________|2____|
______|合计________|7____|
变电 |变电________|2____|
|变电站______|3____|
______|合计________|5____|
.
.
其中:行业是数据库中的UsrType字段,行业分类为UsrSubType参考:
string connstr=System.Configuration.ConfigurationSettings.AppSettings["sqllink"];
SqlConnection conn=new SqlConnection(connstr);
conn.Open();
string sql="select UsrType,UsrSubType from view_usract";
SqlCommand cmd=new SqlCommand(sql,conn);
SqlDataReader dr=cmd.ExecuteReader();
this.Response.Write("<table align='center' border='1'>");
this.Response.Write("<tr>");
this.Response.Write("<td align='left'>");
this.Response.Write("用户行业");
this.Response.Write("</td>");
this.Response.Write("<td align='left'>");
this.Response.Write("行业分类");
this.Response.Write("</td>");
this.Response.Write("<td align='left'>");
this.Response.Write("用户数量");
this.Response.Write("</td>");
this.Response.Write("</tr>");
while(dr.Read())
{
this.Response.Write("<tr>");
this.Response.Write("<td align='left'>");
this.Response.Write(dr["UsrType"].ToString());
this.Response.Write("</td>");
this.Response.Write("<td align='left'>");
this.Response.Write(dr1["UsrSubType"].ToString());
this.Response.Write("</td>");
this.Response.Write("<td align='left'>");
this.Response.Write(dr1["UsrSubType"].ToString());
this.Response.Write("</td>");
this.Response.Write("</tr>");
}
this.Response.Write("</table>");
conn.Close();
--blackhero--
你不要用RESPONSE.WRITE("<table>")这一类的方法,在HTML控件中有一个表格控件,它有<table runat="server">其中又有rowcount和colcount什么属性(记不清楚了,你要去查些资料)然后你可以通过一个控件程序动态的生成各种各样的表格
谁有没有源代码呀(c#)
我也给50分
在线在线
在线在线
在线在线
在线在线在线在线
在线在线
在线在线在线在线在线在线在线在线在线在线在线在线在线在线在线在线
可以看http://dev.csdn.net/develop/article/65/article/67/67551.shtm