3 回答

TA贡献1818条经验 获得超11个赞
我自己原来循环输出过一个TABLE 你参照一下吧!
if (ds != null)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
Response.Write("<tr> <th width=\"31\" height=\"40\" class=\"style7\" scope=\"row\">" + ds.Tables[0].Rows[i]["g_no"] + "</th>");
Response.Write("<th width=\"80\" height=\"40\" class=\"tdbtable2\">" + ds.Tables[0].Rows[i]["code_t"] + ds.Tables[0].Rows[i]["code_s"] + "</td>");
Response.Write("<th colspan=\"4\" height=\"40\" class=\"tdbtable2\">" + ds.Tables[0].Rows[i]["g_name"] + " " + ds.Tables[0].Rows[i]["g_model"] + "</td>");
Response.Write("<th colspan=\"2\" height=\"40\" class=\"tdbtable2\">" + ds.Tables[0].Rows[i]["qty_1"] + " " + ds.Tables[0].Rows[i]["name3"] + "</br>" + ds.Tables[0].Rows[i]["qty_conv"].ToString() + " " + ds.Tables[0].Rows[i]["unit_name"] + "</br>" + ds.Tables[0].Rows[i]["qty_2"] + " " + ds.Tables[0].Rows[i]["name2"] + "</td>");
Response.Write("<th colspan=\"3\" height=\"40\" class=\"tdbtable2\">(" + ds.Tables[0].Rows[i]["origin_cou"] + ")</br>" + ds.Tables[0].Rows[i]["country_na"] + "</td>");
Response.Write("<th height=\"40\" class=\"tdbtable2\">" + ds.Tables[0].Rows[i]["decl_price"] + "</td>");
Response.Write("<th height=\"40\" class=\"tdbtable2\">" + ds.Tables[0].Rows[i]["trade_tota"] + "</td>");
Response.Write("<th height=\"40\" class=\"tdbtable2\">(" + ds.Tables[0].Rows[i]["trade_curr"] + ")</br>" + ds.Tables[0].Rows[i]["curr_name"] + "</td>");
Response.Write("<th height=\"40\" class=\"style8\">" + ds.Tables[0].Rows[i]["duty_spec"] + "</td></tr>");
}
}
忘记写了,前台ASPX页面写<%showlist();%>类似这样的方法。。。直接写个TABLE里就可以了!
加<tr>不就可以了么。。。。看上边代码的TR是怎么加的 然后你改造一下 在循环里再嵌套一层负责将一行数据分割几行TD显示...

TA贡献1806条经验 获得超5个赞
很简单 直接贴代码给你看
<%for (int i = 0; i < 10; i++)
{ %>
<table>
<tr>
<td>
<td>
</tr>
</table>
<% }%>
类似这样的就可以循环了~~

TA贡献1993条经验 获得超6个赞
用取余数的方法
<table>
<tr>
for (int i =0 ;i<10;i++)
{
if ((i+1) %3 == 0)
{
//Response.Write("<td>单元格</td>");
Response.Write("</tr><tr>");
}
}
</tr>
</table>
- 3 回答
- 0 关注
- 254 浏览
添加回答
举报