使用DataList
<asp:datalist id="DataList1" runat="server" Width="90%">
<HeaderTemplate>
<table border="0" width="100%" bordercolor="#FF0000" align="center">
<tr>
<td width="7%" nowrap bgcolor="dbdbdb" class="p1" align="center">编号</td>
<td width="29%" nowrap bgcolor="dbdbdb" class="p1" align="center">主题</td>
<td width="15%" nowrap bgcolor="dbdbdb" class="p1" align="center">作者</td>
<td width="19%" nowrap bgcolor="dbdbdb" class="p1" align="center">发表时间</td>
<td width="15%" nowrap bgcolor="dbdbdb" class="p1" align="center">回复/浏览次数</td>
<td width="15%" nowrap bgcolor="dbdbdb" class="p1" align="center">最后回复</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table border="0" width="100%" bordercolor="#FF0000" align="center">
<tr>
<td width="7%" class="p1" align="center" bgcolor="f7f7f7">&nbsp;<%# Container.ItemIndex+1 %></td>
<td width="29%" class="p1" bgcolor="f7f7f7">&nbsp;<a href='Detail.aspx?RootID=<%# DataBinder.Eval(Container.DataItem,"ReferID") %>' target="_self"><font color="#000000"><%# DataBinder.Eval(Container.DataItem,"Subject") %></font></a></td>
<td width="15%" class="p1" bgcolor="f7f7f7">&nbsp;<%# DataBinder.Eval(Container.DataItem,"Name") %></td>
<td width="19%" class="p1" align="center" bgcolor="f7f7f7">&nbsp;<%# DataBinder.Eval(Container.DataItem,"PostDate") %></td>
<td width="15%" class="p1" align="center" bgcolor="f7f7f7">&nbsp;<%# DataBinder.Eval(Container.DataItem,"Child") %>/<%# DataBinder.Eval(Container.DataItem,"Hits") %></td>
<td width="15%" class="p1" align="center" bgcolor="f7f7f7">&nbsp;<%# GetLastReplayName(DataBinder.Eval(Container.DataItem,"LastPost").ToString()) %></td>
</tr>
</table>
</ItemTemplate>
</asp:datalist>

解决方案 »

  1.   

    用DataGrid,建议你先看看Microsoft ASP.NET 快速入门教程
      

  2.   

    http://chs.gotdotnet.com/quickstart/aspplus/doc/webdataaccess.aspx
    仔细看看!
      

  3.   

    建议写在cs文件里,这样层次更清晰
    一种是用dataset
    datasetName.Table["tablename"].DefaultView来邦定
    另外一种是用datareader
    返回一个datareader后
    用一个对象数组来存组数据
    因为arraylist是从IList接口派生的,所以也能用来邦定