private void drawtable()
{
SqlConnection myconn = new SqlConnection(conn);
myconn.Open();
SqlCommand cmd = new SqlCommand("select serverid,servername,servercontent from server where serverid%2=1", myconn);
int count = (int)cmd.ExecuteScalar();
SqlDataReader dataread = cmd.ExecuteReader();
Response.Write(count);
string output="<table width='300' border='0' cellspacing='0' cellpadding='0'>";
while (dataread.Read())
{
output += "<tr><td background=images/zxfw_16_01.jpg width=139 height=26>" + dataread["servername"].ToString();
output += "</td>";//服务名称
output += "<td width=66 height=26 bgcolor=#C6E2F0>更多</td>";//该服务内容的详细问题列表
output += "</tr>";
output += "<tr><td colspan=2 background=Images/zxfw_24_02.jpg>" + dataread["servercontent"].ToString();
output += "</td>";//该服务的简单介绍
output += "</tr>";
SqlConnection myconn1 = new SqlConnection(conn);
myconn1.Open();
SqlCommand cmd1 = new SqlCommand("select questionid,questiontitle from question where serverid='" + dataread["serverid"] + "'", myconn1);
SqlDataReader datareadtitle = cmd1.ExecuteReader();
while (datareadtitle.Read())
{
output += "<tr>";
output += "<td colspan=2 background=Images/zxfw_24_02.jpg>" + datareadtitle["questiontitle"].ToString();
output += "</td>";//该服务下的问题列表
output += "</tr>";
}
output += "<tr>";
output += "<td colspan=2><img src=Images/zxfw_26.jpg width=345 height=6></td>";
output += "</tr>";
output += "<tr>";
output += "<td colspan=2 height=3><img src=images/zxfw_24_03.jpg width=345 height=3></td>";
output += "</tr>"; }
output += "</table>";
Response.Write(output);
}问个问题啊,如何把这个在后台通过代码画的表格在页面的指定单元格里循环画表呢??
{
SqlConnection myconn = new SqlConnection(conn);
myconn.Open();
SqlCommand cmd = new SqlCommand("select serverid,servername,servercontent from server where serverid%2=1", myconn);
int count = (int)cmd.ExecuteScalar();
SqlDataReader dataread = cmd.ExecuteReader();
Response.Write(count);
string output="<table width='300' border='0' cellspacing='0' cellpadding='0'>";
while (dataread.Read())
{
output += "<tr><td background=images/zxfw_16_01.jpg width=139 height=26>" + dataread["servername"].ToString();
output += "</td>";//服务名称
output += "<td width=66 height=26 bgcolor=#C6E2F0>更多</td>";//该服务内容的详细问题列表
output += "</tr>";
output += "<tr><td colspan=2 background=Images/zxfw_24_02.jpg>" + dataread["servercontent"].ToString();
output += "</td>";//该服务的简单介绍
output += "</tr>";
SqlConnection myconn1 = new SqlConnection(conn);
myconn1.Open();
SqlCommand cmd1 = new SqlCommand("select questionid,questiontitle from question where serverid='" + dataread["serverid"] + "'", myconn1);
SqlDataReader datareadtitle = cmd1.ExecuteReader();
while (datareadtitle.Read())
{
output += "<tr>";
output += "<td colspan=2 background=Images/zxfw_24_02.jpg>" + datareadtitle["questiontitle"].ToString();
output += "</td>";//该服务下的问题列表
output += "</tr>";
}
output += "<tr>";
output += "<td colspan=2><img src=Images/zxfw_26.jpg width=345 height=6></td>";
output += "</tr>";
output += "<tr>";
output += "<td colspan=2 height=3><img src=images/zxfw_24_03.jpg width=345 height=3></td>";
output += "</tr>"; }
output += "</table>";
Response.Write(output);
}问个问题啊,如何把这个在后台通过代码画的表格在页面的指定单元格里循环画表呢??
解决方案 »
- 怎样做到页面刷新位置保持不变?
- 如何将gridview模板列中的checkbox作为updatepanel的Triggers?
- fckeditor上传图片问题
- 再次提问,关于获取局域网内客户端硬件配置
- 新手求助:.net操作cookies
- 限制输入格式的问题(初学者请多多帮忙)
- 自定义基页加载用户控件和自定义控件问题?期待高手
- 怎么自动获取文章标题的关键字
- 使用asp.net+sql server做了一个网站...有些问题需要大家帮助...
- 请问!!可不可以继承已排版好的asp.net窗体,然后在另外一个页面继承并再修改它???
- csdn论坛中 时不时弹出的消息框是怎样做出来的?
- !!局域网直播的问题??
{
SqlConnection myconn = new SqlConnection(conn);
myconn.Open();
SqlCommand cmd = new SqlCommand("select serverid,servername,servercontent from server where serverid%2=1", myconn);
int count = (int)cmd.ExecuteScalar();
SqlDataReader dataread = cmd.ExecuteReader();
Response.Write(count);
string output=" <table width='300' border='0' cellspacing='0' cellpadding='0'> ";
while (dataread.Read())
{
output += " <tr> <td background=images/zxfw_16_01.jpg width=139 height=26> " + dataread["servername"].ToString();
output += " </td> ";//服务名称
output += " <td width=66 height=26 bgcolor=#C6E2F0> 更多 </td> ";//该服务内容的详细问题列表
output += " </tr> ";
output += " <tr> <td colspan=2 background=Images/zxfw_24_02.jpg> " + dataread["servercontent"].ToString();
output += " </td> ";//该服务的简单介绍
output += " </tr> ";
SqlConnection myconn1 = new SqlConnection(conn);
myconn1.Open();
SqlCommand cmd1 = new SqlCommand("select questionid,questiontitle from question where serverid='" + dataread["serverid"] + "'", myconn1);
SqlDataReader datareadtitle = cmd1.ExecuteReader();
while (datareadtitle.Read())
{
output += " <tr> ";
output += " <td colspan=2 background=Images/zxfw_24_02.jpg> " + datareadtitle["questiontitle"].ToString();
output += " </td> ";//该服务下的问题列表
output += " </tr> ";
}
output += " <tr> ";
output += " <td colspan=2> <img src=Images/zxfw_26.jpg width=345 height=6> </td> ";
output += " </tr> ";
output += " <tr> ";
output += " <td colspan=2 height=3> <img src=images/zxfw_24_03.jpg width=345 height=3> </td> ";
output += " </tr> "; }
output += " </table> ";
return output;
//Response.Write(output);
} 类似这样,把这个方法放到你的循环里
string d = "<table border=1><tr><td>dddd</td></tr></table>";
Label1.Text = d;
{
SqlConnection myconn = new SqlConnection(conn);
myconn.Open();
SqlCommand cmd = new SqlCommand("select serverid,servername,servercontent from server where serverid%2=1", myconn);
int count = (int)cmd.ExecuteScalar();
SqlDataReader dataread = cmd.ExecuteReader();
Response.Write(count);
string output=" <table width='300' border='0' cellspacing='0' cellpadding='0'> ";
while (dataread.Read())
{
output += " <tr> <td background=images/zxfw_16_01.jpg width=139 height=26> " + dataread["servername"].ToString();
output += " </td> ";//服务名称
output += " <td width=66 height=26 bgcolor=#C6E2F0> 更多 </td> ";//该服务内容的详细问题列表
output += " </tr> ";
output += " <tr> <td colspan=2 background=Images/zxfw_24_02.jpg> " + dataread["servercontent"].ToString();
output += " </td> ";//该服务的简单介绍
output += " </tr> ";
SqlConnection myconn1 = new SqlConnection(conn);
myconn1.Open();
SqlCommand cmd1 = new SqlCommand("select questionid,questiontitle from question where serverid='" + dataread["serverid"] + "'", myconn1);
SqlDataReader datareadtitle = cmd1.ExecuteReader();
while (datareadtitle.Read())
{
output += " <tr> ";
output += " <td colspan=2 background=Images/zxfw_24_02.jpg> " + datareadtitle["questiontitle"].ToString();
output += " </td> ";//该服务下的问题列表
output += " </tr> ";
}
output += " <tr> ";
output += " <td colspan=2> <img src=Images/zxfw_26.jpg width=345 height=6> </td> ";
output += " </tr> ";
output += " <tr> ";
output += " <td colspan=2 height=3> <img src=images/zxfw_24_03.jpg width=345 height=3> </td> ";
output += " </tr> "; }
output += " </table> ";
return output;
//Response.Write(output);
}
能给一个详尽的代码么??int type不知道作用,以及引用方法先谢谢啊