我不确定我做错了什么。我正在尝试在页面上显示图像,它将显示 url 但不显示图像。我尝试了作为模板字段和图像字段。使用 Firebug,我可以看到图像源的价值。
页面:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ImageID" DataSourceID="Images">
<Columns>
<asp:BoundField DataField="ImageID" HeaderText="ImageID" InsertVisible="False" ReadOnly="True" SortExpression="ImageID" />
<asp:BoundField DataField="InciID" HeaderText="InciID" SortExpression="InciID" />
<asp:TemplateField HeaderText="Imagepath" SortExpression="Imagepath">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Imagepath") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:image runat="server" ID="Label1" ImageUrl='<%# Bind("Imagepath") %>'></asp:image>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ImageDescription" HeaderText="ImageDescription" SortExpression="ImageDescription" />
<asp:BoundField DataField="Category" HeaderText="Category" SortExpression="Category" />
<asp:ImageField DataImageUrlField="Imagepath">
<ControlStyle Height="100px" Width="100px" />
</asp:ImageField>
</Columns>
</asp:GridView>
Firebug的网页源代码:
<td><img id="ctl00_ContentPlaceHolder1_GridView1_ctl15_Label1" src="images\curiouskids.jpg"></td>
<td><img style="height:100px;width:100px;" src="images\curiouskids.jpg"></td>