来源:互联网 发布:知乎 出租屋衣帽架 编辑:程序博客网 时间:2024/06/14 01:19
 

从数据库中搜索照片并在表格中显示出来

 

 protected void Page_Load(object sender, EventArgs e)
    {
        string str = "select * from Users ";
        DataTable table =SqlHelper .ExecuteTable(str);
        Table table1 = new Table();
        foreach (DataRow rows in table.Rows)
        {
            FriendList(table1, rows);
        }
        this.Panel1.Controls.Add(table1);
       
    }
    private void FriendList(Table table1, DataRow rows)
    {
        TableRow row = new TableRow();
        TableCell cell = new TableCell();

        Image img = new Image();
        img.Width = 50;
        img.Height = 50;
        img.ImageUrl = rows["touxiang"].ToString();
        cell.Controls.Add(img);
        row.Cells.Add(cell);
        table1.Rows.Add(row);

        row.Cells.Add(cell);

        table1.Rows.Add(row);