Hi varun3752,
Check this example. Now please take its reference and correct your code.
HTML
CS.aspx
<div>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
<asp:DataList ID="dlCustomers" runat="server" RepeatColumns="6" CellSpacing="0" RepeatLayout="Table">
<ItemTemplate>
<table class="table">
<tr>
<th colspan="2">
<b>
<%# Eval("Name") %></b>
</th>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lblId" Text='<%# Eval("id") %>' runat="server" />,
<%# Eval("ContentType") %>
</td>
</tr>
<tr>
<td>
Image:
</td>
<td>
<asp:ImageButton ID="imgImage" runat="server" ImageUrl='<%# "data:image/jpg;base64," + Convert.ToBase64String((byte[])Eval("Data")) %>'
Height="75px" Width="75px" OnClick="imgImage_Click" />
</td>
</tr>
<tr>
<td colspan="2">
Name:
<%# Eval("Name")%>
</td>
</tr>
<tr>
<td colspan="2">
ContentType:
<%# Eval("ContentType")%>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</div>
Namespaces
C#
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.WebControls;
Code
CS.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = this.GetData();
dlCustomers.DataSource = dt;
dlCustomers.DataBind();
}
}
protected void imgImage_Click(object sender, EventArgs e)
{
Response.Redirect("Details.aspx?Id=" + ((sender as ImageButton).NamingContainer.FindControl("lblId") as Label).Text);
}
private DataTable GetData()
{
string conString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlCommand cmd = new SqlCommand("SELECT Id,Name,ContentType,Data FROM tblFiles WHERE ContentType = 'image/jpeg'"))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
return dt;
}
}
}
}
}
Details.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(Request.QueryString["Id"]))
{
Response.Write("Id is : <b>" + Request.QueryString["Id"] + "</b>");
}
}
Screenshot
![](https://i.imgur.com/1j1b79H.gif)