这类数据格式应该怎么循环? <div id="div_0">123123123123123</div><div id="div_1">123123123123123</div>数据已经用dataset取出来了..现在需要怎么循环出需要的格式.. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 牛人都是由菜鸟做起的,加油。foreach(DataRow dr in ds.Rows){...}for(int i=0;i<ds.Rows.Count; i++){...} for(int i=0;i<ds.Tables[0].Rows.Count; i++){}StringBuilder 可以在读取出来的字段前"<p>"+字段+"</p>"或是在字段后面加"<br />" //这里说明下.好像不是加<br /> 是加"\r"(/r)你都试下吧 看来大家没看清楚问题..如果只是直接循环出来,是没任何问题的...主要是每5条外面都要有一个div包含在里面 foreach (DataRow dr in ds.Tables[0].Rows) { if (i % 5 == 1) { strTable += "<div id='search_p_" + j + "' name='search_p_" + j + "' style='display: none'>"; j += 1; } strTable += "<table style='display: inline; width: 79px; height: 72px' cellpadding='0' cellspacing='0'>"; strTable += " <tr>"; strTable += " <td>"; strTable += " <div style='margin: 1px; padding: 1px; border-color: #E0E0E0; border-style: solid;border-width: 1px; width: 79px; height: 72px'>"; strTable += " <a target='_parent' href='Goods.aspx?id=" + dr["ProductID"] + "' title=''><img src='"+dr["PhotoUrl"]+"' border='0' alt='' height='77'></a>"; strTable += " </div>"; strTable += " </td>"; strTable += " </tr>"; strTable += " <tr>"; strTable += " <td align='center'>"; strTable += " <span class='price'>$" + Math.Round(Convert.ToDecimal(dr["PriceCuXiao"]), 2) + "</span>"; strTable += " </td>"; strTable += " </tr>"; strTable += " </table>"; if (i % 5 == 0) { strTable += "</div>"; } i += 1; }已经解决了...贴出来 sql语句的时间格式问题 请问,提交数据 如何在客户端用 JS 得到 页面得验证控件是否验证通过 URL中的逗号是怎么一回事? ggjj们,帮帮忙吧!!如何互相调用不同文件夹下的窗体?? 关于treeview--怎么为节点做一个tip? 脚本--一闪而过?? 巨难问题?哭求程序? 为什么我的可用分不增长了?难道csdn程序有bug? 简单的helloworld为什么不能运行 请求REST服务时,怎么设置request body <form id="form1" runat="server">是啥意思?
foreach(DataRow dr in ds.Rows){...}for(int i=0;i<ds.Rows.Count; i++){...}
StringBuilder
或是在字段后面加"<br />" //这里说明下.好像不是加<br /> 是加"\r"(/r)你都试下吧
如果只是直接循环出来,是没任何问题的...主要是每5条外面都要有一个div包含在里面
foreach (DataRow dr in ds.Tables[0].Rows)
{
if (i % 5 == 1)
{
strTable += "<div id='search_p_" + j + "' name='search_p_" + j + "' style='display: none'>";
j += 1;
} strTable += "<table style='display: inline; width: 79px; height: 72px' cellpadding='0' cellspacing='0'>";
strTable += " <tr>";
strTable += " <td>";
strTable += " <div style='margin: 1px; padding: 1px; border-color: #E0E0E0; border-style: solid;border-width: 1px; width: 79px; height: 72px'>";
strTable += " <a target='_parent' href='Goods.aspx?id=" + dr["ProductID"] + "' title=''><img src='"+dr["PhotoUrl"]+"' border='0' alt='' height='77'></a>";
strTable += " </div>";
strTable += " </td>";
strTable += " </tr>";
strTable += " <tr>";
strTable += " <td align='center'>";
strTable += " <span class='price'>$" + Math.Round(Convert.ToDecimal(dr["PriceCuXiao"]), 2) + "</span>";
strTable += " </td>";
strTable += " </tr>";
strTable += " </table>";
if (i % 5 == 0)
{
strTable += "</div>";
} i += 1;
}
已经解决了...贴出来