i have got a datatable in witch i have got image url. i dont want to create a tamplet column. i just want to assign my datatable as datasource of gridview and it should show image in its field like:
dim dt as new datatable
dr = dt.NewRow
dr("HotelName") = "citypalace"
dr("image") ="<img src='" & "www.mycity.com/aa.jpg" & "'/>" 'but this is not working its showing url in that column...
dt.rows.add(dr)
gridview1.datasource = dt
gridview1.databind()
please give me solution that what should i do with that column of datatable so it will show image in gridview. (please dont say me to create a template column).
The GridView control automatically html-encodes everything, but there are a couple ways you can turn it off. If you have the image field declared in the aspx page, the easiest option is to just set the
HtmlEncodeproperty to false.If this isn’t feasible in your case, you can ‘undo’ the html encoding for these cells on the GridView’s
RowDataBoundevent.I’m assuming from your example that your GridView has 2 columns and the image column is the second one, hence Cells(1) in each row. Hope this helps!