My code
Can’t display image in GridView
My image path is Images/img.jpg. Please help fix this code
I would prefer image field because i want to use it to pass the value id to another page via DataNavigateUrlFormatString="CustomerDetails.aspx?Id={0}".The image cant perform this function
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="Data Source=edu\SQLEXPRESS01;Initial Catalog=School;Integrated Security=True"
ProviderName="System.Data.SqlClient"
SelectCommand="SELECT [Id], [Name], [Photo], [RollNo] FROM [tbl_class] ">
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Id"
DataSourceID="SqlDataSource2" AllowPaging="True" AllowSorting="True"
style="margin-right: 1px" Width="676px" BackColor="White"
BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False"
ReadOnly="True" SortExpression="Id" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="Photo" HeaderText="Photo" SortExpression="Photo" />
<asp:BoundField DataField="RollNo" HeaderText="RollNo"
SortExpression="RollNo" />
<asp:HyperLinkField DataNavigateUrlFields="Id,Name"
DataNavigateUrlFormatString="CustomerDetails.aspx?Id={0}&Name={1}"
Text="Pass Single Value" />
<asp:ImageField DataImageUrlFormatString="~/Images/img.jpg" >
</asp:ImageField>
</Columns>
</asp:GridView>