Display Images Using Database:
In ASP.NET you can display images using database. That task can be performed through different controls. However, I have used a DataList and a SqlDataSource for that purpose. Following is the step by step procedure for doing that task.
Step1: Create a table in Sql server 2008 and imageid, Title and Picture fields in that table. In the Picture field store URL of images that you want to display.
Step2: Drag a DataList and a SqlDataSource control on your .aspx page.
Step3: Now bind the Datalist to that Sql data Source. You can bind it either through code view of .aspx page or through design view. Now your code at .aspx page will be like below.
<form id="form1" runat="server">
<div align="center" class="pageHeading">
Display Image From Database
<br />
<asp:DataList ID="DataList1" runat="server"
DataSourceID="SqlDataSource1"
RepeatColumns="3" Height="192px">
<ItemTemplate>
<br />
//bind Picture field of the data source using HTML <img> tag
<img id="Picture" runat="server" src='<%# Eval("Picture") %>'/>
<br />
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Title") %>' />
<br />
<br />
</ItemTemplate>
</asp:DataList>
</div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ProductsConnectionString %>"
SelectCommand="SELECT [Title], [Picture] FROM [Images]"></asp:SqlDataSource>
</form>
