在后台写了一个方法,获得DataSet数据,在前台的Table里希望通过for循环把每一个数据遍历在<td></td>中显示?请问各位大虾怎么写???
如:后台
public DataSet GetType
{
    DataSet ds=TypeManager.GetType();
    return ds;
}
前台
<table><tr><td>  <%# Bind("TypeName") %> </td></tr></table>如何循环遍历????

解决方案 »

  1.   

    DataSet
    你可以直接使用绑定控件啊~~
    Repeater就行~
      

  2.   

    <asp:Repeater id="rList"...>
         <ItemTemplate>
               <%# Eval("abc")%>
         </ItemTemplate>
    </asp:Repeater>rList.DataSource = GetType;
    rList.DataBind();
      

  3.   

    .NET思想的话一般用控件进行绑定显示。
    否则按你说的思想的话可能更接近于asp思想
      

  4.   

    可以直接邦定,如果要遍历的话大概如下:
    前台
    <table>
    <tr>
    <% 
    DataTable table = GetType.Tables[0];
    foreach(DataRow row in table.Rows)
    {
    %>
    <td><%row["TypeName"].ToString()%></td>
    <%
    }
    %>
    </tr>
    </table>
      

  5.   

      foreach (DataRow dr in ds.Tables[0].Rows)
                {
                  ..
           foreach (DataColumn dc in ds.Tables[0].Columns)
                    {
                        .......
                    }
      

  6.   

    在后台声明一个全局变量  public string aa="";
    aa="<table>";
    for(int i =0;i<ds.table[0].rows.count;i++){
           aa="<tr>";
           aa="<td>"+ds.tables[0].rows[i][0].ToString()+"</td>";
           aa="<td>"+ds.tables[0].rows[i][0].ToString()+"</td>";
           aa="</tr>";
    }
    aa="</table>";红色的内容,你根据需要添加。然后在页面要用到的地方调用aa就行了,代码:<%= aa %>
      

  7.   


    __doPostBack('ServerFunction','');