Hi akhter,
Refer below sample.
HTML
CS.aspx
<asp:DataList ID="dlemp" runat="server" RepeatDirection="Horizontal" RepeatColumns="2">
<ItemTemplate>
<div id="pricePlans">
<ul id="plans">
<li class="plan">
<ul class="planContainer">
<li class="title">
<h2>
<asp:Label ID="ProductName" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
<br />
</li>
<li class="title">
<asp:Image ID="imgEmp" Height="100px" Width="100px" runat="server" ImageUrl='<%# "data:image/jpg;base64," + Convert.ToBase64String((byte[])Eval("Data")) %>' />
</li>
<li>
<ul class="options">
<div>
<li><b>Id: </b>
<asp:Label ID="CustomerID" runat="server" Text=' <%# Eval("Id") %>'></asp:Label>
<asp:CheckBox ID="CheckBox1" runat="server" Text="select" />
</li>
</div>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:DataList>
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="Redirect">ViewDeatils</asp:LinkButton>
ViewDetails.aspx
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:Image ID="Data" runat="server" Width="100px" Height="80px" ImageUrl='<%# "data:image/jpg;base64," + Convert.ToBase64String((byte[])Eval("Data")) %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Namespaces
C#
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
VB.Net
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Data
Code
C#
CS.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand("SELECT top 4 * FROM tblfiles WHERE ContentType='image/pjpeg'", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
dlemp.DataSource = dt;
dlemp.DataBind();
}
}
protected void Redirect(object source, EventArgs e)
{
string id = "";
foreach (DataListItem item in dlemp.Items)
{
CheckBox chk = item.FindControl("CheckBox1") as CheckBox;
if (chk.Checked)
{
id += (item.FindControl("CustomerID") as Label).Text + ",";
}
}
Response.Redirect("ViewDetails.aspx?Id=" + id.TrimEnd(','));
}
ViewDetails.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand("SELECT * FROM tblfiles where Id IN(" + Request.QueryString[0].ToString() + ")", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
VB.Net
CS.aspx.vb
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)Handle Me.Load
If Not Me.IsPostBack Then
Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Dim con As SqlConnection = New SqlConnection(constr)
Dim cmd As SqlCommand = New SqlCommand("SELECT top 4 * FROM tblfiles WHERE ContentType='image/pjpeg'", con)
Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim dt As DataTable = New DataTable()
da.Fill(dt)
dlemp.DataSource = dt
dlemp.DataBind()
End If
End Sub
Protected Sub Redirect(ByVal source As Object, ByVal e As EventArgs)
Dim id As String = ""
For Each item As DataListItem In dlemp.Items
Dim chk As CheckBox = TryCast(item.FindControl("CheckBox1"), CheckBox)
If chk.Checked Then
id += (TryCast(item.FindControl("CustomerID"), Label)).Text & ","
End If
Next
Response.Redirect("ViewDetails.aspx?Id=" & id.TrimEnd(","c))
End Sub
ViewDetailsVB.aspx.vb
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)Handle Me.Load
If Not Me.IsPostBack Then
Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Dim con As SqlConnection = New SqlConnection(constr)
Dim cmd As SqlCommand = New SqlCommand("SELECT * FROM tblfiles where Id IN(" & Request.QueryString(0).ToString() & ")", con)
Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim dt As DataTable = New DataTable()
da.Fill(dt)
GridView1.DataSource = dt
GridView1.DataBind()
End If
End Sub
Screenshot