Gridview模板显示数据库中图像问题
我在做C#.net的web网页应用开发
数据库中存有手机信息以及相应的图片路径,数据库存的是图片相对路径,如:~/Images/1.jpg,然后想用个gridview模板把手机的信息以及其对应的图片显示出来,形成个列表。
下面是前台代码:
<asp:GridView ID="GridView1" runat="server" Width="100%"
AutoGenerateColumns="False" Font-Size="Small" Height="16px"
style="margin-right: 0px"
EmptyDataText="No Records" PageSize="5" ShowHeader="False" onselectedindexchanged="GridView1_SelectedIndexChanged"
>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table style=" border:1px thin solid #6699FF; width:100%" >
<tr>
<td style="border-color: #00FFFF; height: 19px; text-align: left;">
Product ID:<font color='#FF0000'><%# DataBinder.Eval(Container.DataItem, "pid")%></font>
Product Name:<font color='#FF0000'><%# DataBinder.Eval(Container.DataItem, "pname")%></font> Model:<font color='#FF0000'><%# DataBinder.Eval(Container.DataItem, "model")%></font><br />color:<font color='#FF0000'><%# DataBinder.Eval(Container.DataItem, "color")%></font> Material Quality:<font color='#FF0000'><%# DataBinder.Eval(Container.DataItem, "materialquality")%></font>Quantity:<font color='#FF0000'><%# DataBinder.Eval(Container.DataItem, "quantity")%></font><br />Import Price: <font color='#FF0000'><%# DataBinder.Eval(Container.DataItem, "importprice")%></font> Sale Price: <font color='#FF0000'><%# DataBinder.Eval(Container.DataItem, "saleprice")%></font> Supplier <font color='#FF0000'><%# DataBinder.Eval(Container.DataItem, "supplier")%></font>
<br />Image:<font color='#FF0000'><%# DataBinder.Eval(Container.DataItem, "image")%></font> Description: <font color='#FF0000'><%# DataBinder.Eval(Container.DataItem, "description")%></font> </tr>
<asp:Image ID="Image1" runat="server" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "image").ToString)%>'/>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
后台代码:
protected void bind()
{
String qs = "select pid, pname, model, color, materialquality, importprice, saleprice, quantity, supplier, image, description from product ";
DB dbb = new DB();
DataSet ds = dbb.GetData(qs);//GetData(queryString);
if (ds.Tables.Count > 0)
{
Gri