Just store the image URL in the DataTable rather than the actual image. Then, use a TemplateField
in your GridView and put an Image in the ItemTemplate
:
<asp:TemplateField>
<ItemTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("ImageUrlColumn") %>' ... />
</ItemTemplate>
</asp:TemplateField>
You can also use an ImageField
:
<asp:ImageField DataImageUrlField="ImageNameColumn" DataImageUrlFormatString="/images/{0}"></asp:ImageField>
EDIT
When declaring columns, try this instead:
dt.Columns.Add("Image", typeof(string));
And to set the value of the image column, try this:
dr.SetField<string>("Image", "img.png");
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…