尝试将jpg图片添加到数据表dtsun。 我该怎么做?
Dim dtsun As New DataTable()
dtsun.Columns.Add("col1")
dtsun.Columns.Add("col2")
dtsun.Columns.Add("col3")
dtsun.Rows.Add(ImageUrl("~/jpg/" & col1name & ".jpg"), ImageUrl("~/jpg/" & col2name & ".jpg"), ImageUrl("~/jpg/" & col3name & ".jpg"))
GridView1.DataSource = dtsun
GridView1.DataBind()
答案 0 :(得分:0)
您可以直接在网格视图中添加图像列。.因此,您无需在dt中添加图像列。可以这样做
GridName.Columns.Clear()
Dim ds As DataSet = SqlHelper.ExecuteDataset(connect(), CommandType.StoredProcedure, ProcedureName, Parameter)
Dim DT As DataTable = ds.Tables(0)
GridName.DataSource = DT
Dim img As New DataGridViewImageColumn()
Dim inImg As System.Drawing.Image = My.Resources.edit
img.Image = inImg
img.HeaderText = "Edit"
img.ToolTipText = "Edit"
GridName.Columns.Add(img)
img.DefaultCellStyle.BackColor = System.Drawing.Color.MediumAquamarine