A方式: <asp:DataList ID="DataList1" runat="server" RepeatColumns="" RepeatDirection="Horizontal"> </asp:DataList> RepeatDirection="Horizontal"這個是橫著顯示,RepeatColumns=""這個是一行顯示幾個 B方式: <asp:table id="tb1" runat="server"> </asp:table> 假設你一行顯示3條,,后臺代碼: DataTable dt = 取得數據; TableRow tr = null; for(int i=0;i <dt.Rows.Count;i++){ if((i % 3) == 0){ tr = new TableRow(); tb1.Rows.Add(tr); } TableCell td = new TableCell(); tr.Cells.Add(td); td.Text = string.Format(" <a href='{0}'> <img src='{1}'> </a>", dt.Rows[… |
|