假设编写一个ASP.NET,使用动态表格生成技术,

来源:百度知道 编辑:UC知道 时间:2024/06/29 22:57:34
将存储Application对象或Cache对象中数据项的名字及其值显示在表格中。

不清楚你想用哪种表格,数据表DataTable,还是控件式的表格Table,索性两个都做了一个:

protected void Page_Load(object sender, EventArgs e)
{
Application["a"] = "11111111";
Application["b"] = "22222222222";
//数据表
DataTable dt = new DataTable();
//控件表格
Table table = new Table();
dt.Columns.Add("key", Type.GetType("System.String"));
dt.Columns.Add("value", Type.GetType("System.String"));
for (int i = 0; i < Application.Count; i++)
{
string key = Application.Keys[i];
string value=Application[i].ToString();
DataRow row=dt.NewRow();
row[0] = key;
row[1] = value;
dt.Rows.Add(row);
TableRow trow = new TableRow();
trow.Cells.Add(new TableCell());