1 回答

TA貢獻1842條經驗 獲得超13個贊
您可以使用 ASP.NET 服務器端表格控件,然后動態添加行并為每一行添加所需的單元格,如下面的代碼
ASPX
<asp:Table ID="myTable" runat="server" Width="100%">
</asp:Table>
ASPX.CS
foreach (DataRow row in tlds.Rows)
{
date = row["releaseDate"].ToString();
price = Convert.ToDouble(row["price"]);
tags = row["tags"].ToString();
TableRow row = new TableRow();
TableCell TLIdCell= new TableCell();
TLIdCell.Text = Convert.ToInt32(row["tldID"]);
row.Cells.Add(TLIdCell);
TableCell tldNameCell = new TableCell();
tldNameCell .Text = Convert.ToString(row["tldName"]);
row.Cells.Add(tldNameCell);
//Similarly add code for date, price and tags cells
// Finally add row to table rows collection
myTable.Rows.Add(row);
}
- 1 回答
- 0 關注
- 136 瀏覽
添加回答
舉報