数据表的应用

来源:互联网 发布:ubuntu 删除软件命令 编辑:程序博客网 时间:2024/06/15 14:22

//创建表 

DataTable dt = new DataTable();

 

//添加列
        DataColumn dc = new DataColumn("id", typeof(int));
        dt.Columns.Add(dc);
        dc = new DataColumn("name", typeof(string));
        dt.Columns.Add(dc);
  

//添加行

        TableRow row = new TableRow();
        TableCell cell = new TableCell();
        cell.Text = reader["name"].ToString();
        row.Cells.Add(cell);

        cell = new TableCell();
        Image img = new Image();
        img.Width = 100;
        img.Height = 150;
        img.ImageUrl = reader["img"].ToString();
        cell.Controls.Add(img);
        row.Cells.Add(cell);

        table.Rows.Add(row);

 

原创粉丝点击