I have been trying to work this out for ages but nothing seems to work.
I am using a database as my source of data, I then fill a Datatable with the restult and bind it to my gridview cntrl.
Here is my code.
Everything works except the button image. All I need to do is make it so that the ButtonField.imageurl is loaded from my database. I dont want one picture for all I want a specific one.Code:dbconn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & (PathVar)) dbconn.Open() da.Fill(ds, "dbs") dbconn.Close() Maxrows = ds.Tables("dbs").Rows.Count Dim dt2 As New DataTable() dt2.Columns.Add(New DataColumn("PictureURL", GetType(String))) dt2.Columns.Add(New DataColumn("Title", GetType(String))) dt2.Columns.Add(New DataColumn("Price", GetType(String))) dt2.Columns.Add(New DataColumn("ButtonField", GetType(String))) dt2.Columns.Add(New DataColumn("id", GetType(String))) Dim dr As DataRow = dt2.NewRow() inc = "0" Dim ButtonField As New ButtonField() For Each dr In ds.Tables("dbs").Rows dr = dt2.NewRow() dr("PictureURL") = ResolveUrl("~/images/" + ds.Tables("dbs").Rows(inc).Item(4) + "") dr("Title") = ds.Tables("dbs").Rows(inc).Item(3).ToString dr("Price") = "£" + ds.Tables("dbs").Rows(inc).Item(2).ToString dr("ButtonField") = ButtonField.ImageUrl("~/images/click.png") '<- when this works I will replace click.png with a database value dr("id") = ds.Tables("dbs").Rows(inc).Item(0) dt2.Rows.Add(dr) dr = dt2.NewRow() inc = inc + 1 Next GridView1.DataSource = dt2 GridView1.DataBind()
Thanks in advance for any help you can give me




Reply With Quote