Hi Sadia.net,
Check this example. Now please take its reference and correct your code.
HTML
Default
<asp:DataList ID="dlemp" runat="server" Font-Names="Verdana" Font-Size="X-Small"
RepeatDirection="Horizontal" RepeatColumns="6" Width="99%" class="dlTable" HorizontalAlign="Center"
Height="100%" BorderColor="Black" ShowFooter="False" ShowHeader="False">
<ItemTemplate>
<div id="pricePlans">
<ul id="plans" style="border-bottom: 0px">
<li class="plan">
<ul class="planContainer" style="border-bottom: 0px">
<li class="title">
<h2>
<asp:Label ID="ProductName" runat="server" Font-Size="X-small" Text='<%# Eval("ProductName") %>'></asp:Label>
<br />
</li>
<li class="title">
<asp:Image ID="imgEmp" runat="server" Width="50%" Height="50%" ImageUrl="~/Chrysanthemum.jpg" />
</li>
<li>
<ul class="options">
<li class="title">
<h2>
<asp:Label ID="Price" runat="server" Font-Size="X-small" CssClass="center" Text='<%# Eval("Price") %>'></asp:Label>
<br />
</li>
<div style="margin-left: 8%">
<li><b>Code: </b>
<asp:Label ID="CustomerID" runat="server" Text=' <%# Eval("Product_id") %>'></asp:Label>
<li style="width: 100%; font-size: x-small;"><a href="ViewDetails.aspx?Id=<%#Eval("Product_id") %>">
Details</a> </li>
<asp:RadioButton ID="RadioButton1" Text="Select" runat="server" />
</li>
</div>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:DataList>
ViewDetails
<div>
Name: <asp:Label ID="lblName" runat="server" /><br />
Price: <asp:Label ID="lblPrice" runat="server" />
</div>
Namespace
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
Default
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
// Populate DataTable from Database.
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.AddRange(new System.Data.DataColumn[] {
new System.Data.DataColumn("Product_id", typeof(int)),
new System.Data.DataColumn("ProductName", typeof(string)),
new System.Data.DataColumn("Price",typeof(decimal)) });
dt.Rows.Add(1, "Product 1", 1000);
dt.Rows.Add(2, "Product 2", 1100);
dt.Rows.Add(3, "Product 3", 1580);
dt.Rows.Add(4, "Product 4", 1256);
dlemp.DataSource = dt;
dlemp.DataBind();
}
}
ViewDetails
protected void Page_Load(object sender, EventArgs e)
{
// Get Product_id from Query String.
if (!string.IsNullOrEmpty(Request.QueryString["Id"]))
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] {
new DataColumn("Product_id", typeof(int)),
new DataColumn("ProductName", typeof(string)),
new DataColumn("Price",typeof(decimal)) });
dt.Rows.Add(1, "Product 1", 1000);
dt.Rows.Add(2, "Product 2", 1100);
dt.Rows.Add(3, "Product 3", 1580);
dt.Rows.Add(4, "Product 4", 1256);
// Filter record based on Product_id.
DataTable product = dt.Select("Product_id=" + Request.QueryString["Id"]).CopyToDataTable();
lblName.Text = product.Rows[0]["ProductName"].ToString();
lblPrice.Text = product.Rows[0]["Price"].ToString();
}
}
VB.Net
Default
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
' Populate DataTable from Database.
Dim dt As System.Data.DataTable = New System.Data.DataTable()
dt.Columns.AddRange(New System.Data.DataColumn() {
New System.Data.DataColumn("Product_id", GetType(Integer)),
New System.Data.DataColumn("ProductName", GetType(String)),
New System.Data.DataColumn("Price", GetType(Decimal))})
dt.Rows.Add(1, "Product 1", 1000)
dt.Rows.Add(2, "Product 2", 1100)
dt.Rows.Add(3, "Product 3", 1580)
dt.Rows.Add(4, "Product 4", 1256)
dlemp.DataSource = dt
dlemp.DataBind()
End If
End Sub
ViewDetails
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
' Get Product_id from Query String.
If Not String.IsNullOrEmpty(Request.QueryString("Id")) Then
Dim dt As DataTable = New DataTable()
dt.Columns.AddRange(New DataColumn() {
New DataColumn("Product_id", GetType(Integer)),
New DataColumn("ProductName", GetType(String)),
New DataColumn("Price", GetType(Decimal))})
dt.Rows.Add(1, "Product 1", 1000)
dt.Rows.Add(2, "Product 2", 1100)
dt.Rows.Add(3, "Product 3", 1580)
dt.Rows.Add(4, "Product 4", 1256)
' Filter record based on Product_id.
Dim product As DataTable = dt.Select("Product_id=" & Request.QueryString("Id")).CopyToDataTable()
lblName.Text = product.Rows(0)("ProductName").ToString()
lblPrice.Text = product.Rows(0)("Price").ToString()
End If
End Sub
Screenshot
![](https://i.imgur.com/0AewuPH.gif)