<div id="div_0">
123
123
123
123
123
</div>
<div id="div_1">
123
123
123
123
123
</div>数据已经用dataset取出来了..现在需要怎么循环出需要的格式..

解决方案 »

  1.   

    牛人都是由菜鸟做起的,加油。
    foreach(DataRow dr in ds.Rows){...}for(int i=0;i<ds.Rows.Count; i++){...}
      

  2.   

    for(int i=0;i<ds.Tables[0].Rows.Count; i++){}
    StringBuilder
      

  3.   

    可以在读取出来的字段前"<p>"+字段+"</p>"
    或是在字段后面加"<br />"  //这里说明下.好像不是加<br /> 是加"\r"(/r)你都试下吧
      

  4.   

    看来大家没看清楚问题..
    如果只是直接循环出来,是没任何问题的...主要是每5条外面都要有一个div包含在里面
      

  5.   


    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;
                    }
    已经解决了...贴出来