Hi vereato,
Use NavigateUrl inside a Repeater control. Set the url with QueryString value.
You need to implement code for Image Click.
When you redirected to the destination page retrieve the data from database based on the QueryString and display other details.
Please refer below sample.
Database
For this example I have used of Northwind database that you can download using the link given below.
Download Northwind Database
HTML
Default
<asp:Repeater runat="server" ID="rptEmployyes">
<ItemTemplate>
<h1><asp:HyperLink NavigateUrl='<%#string.Format("~/Home.aspx?Id={0}", Eval("EmployeeId")) %>' runat="server" Text='<%# Eval("FirstName") %>' /></h1>
<asp:Label Text='<%# Eval("Notes") %>' runat="server" />
<hr>
</ItemTemplate>
</asp:Repeater>
Home
<table>
<tr>
<td>Address:</td>
<td><asp:Label ID="lblAddress" runat="server" /></td>
</tr>
<tr>
<td>City:</td>
<td><asp:Label ID="lblCity" runat="server" /></td>
</tr>
</table>
Namespaces
C#
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
VB.Net
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Code
C#
Default
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.BindRepeater();
}
}
private void BindRepeater()
{
string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlCommand cmd = new SqlCommand("SELECT TOP 3 EmployeeId, FirstName, Notes FROM Employees", con))
{
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
rptEmployyes.DataSource = dt;
rptEmployyes.DataBind();
}
}
}
}
}
Home
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string id = Request.QueryString["Id"];
string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlCommand cmd = new SqlCommand("SELECT EmployeeId, Address, City FROM Employees Where EmployeeId = @Id", con))
{
cmd.Parameters.AddWithValue("@Id", id);
con.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
sdr.Read();
lblAddress.Text = sdr["Address"].ToString();
lblCity.Text = sdr["City"].ToString();
con.Close();
}
}
}
}
}
VB.Net
Default
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Me.BindRepeater()
End If
End Sub
Private Sub BindRepeater()
Dim conString As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using con As SqlConnection = New SqlConnection(conString)
Using cmd As SqlCommand = New SqlCommand("SELECT TOP 3 EmployeeId, FirstName, Notes FROM Employees", con)
Using sda As SqlDataAdapter = New SqlDataAdapter(cmd)
Using dt As DataTable = New DataTable()
sda.Fill(dt)
rptEmployyes.DataSource = dt
rptEmployyes.DataBind()
End Using
End Using
End Using
End Using
End Sub
Home
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim id As String = Request.QueryString("Id")
Dim conString As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using con As SqlConnection = New SqlConnection(conString)
Using cmd As SqlCommand = New SqlCommand("SELECT EmployeeId, Address, City FROM Employees Where EmployeeId = @Id", con)
cmd.Parameters.AddWithValue("@Id", id)
con.Open()
Using sdr As SqlDataReader = cmd.ExecuteReader()
sdr.Read()
lblAddress.Text = sdr("Address").ToString()
lblCity.Text = sdr("City").ToString()
con.Close()
End Using
End Using
End Using
End If
End Sub
Screenshot