Here I will show you, data
will be bind to a table control as a link. When we will click this link all the
respective data related to this link will we shown in a gridview.
Program
Default.aspx
code
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled
Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:Table ID="Table1" runat="server" BackColor="#FFFF80" BorderColor="#FF8080"
BorderStyle="Solid" BorderWidth="5px" ForeColor="Red" GridLines="Both">
<asp:TableRow ID="TableRow1" runat="server">
<asp:TableCell ID="TableCell1" runat="server">Student
Id</asp:TableCell>
</asp:TableRow>
</asp:Table><br />
</form>
</body>
</html>
Default.aspx.vb code
Imports
System.Data.SqlClient
Imports
System.Data
Partial Class _Default
Inherits System.Web.UI.Page
Dim strConnString As String =
System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ToString()
Dim sqlda As
SqlDataAdapter
Dim
com As SqlCommand
Dim ds As
DataSet
Dim dt As
DataTable
Dim str As String
Dim con As New SqlConnection(strConnString)
Protected Sub
Page_Load(ByVal sender
As Object, ByVal
e As System.EventArgs)
Handles Me.Load
con.Open()
str =
"select * from student"
com =
New SqlCommand(str, con)
sqlda =
New SqlDataAdapter(com)
ds =
New DataSet
sqlda.Fill(ds,
"student")
dt = ds.Tables("student")
con.Close()
Dim i As Integer
For i = 0 To
dt.Rows.Count - 1
Dim tr As New TableRow
Dim tc As New TableCell
tc.Text =
"<a href=Default2.aspx?id=" &
ds.Tables(0).Rows(i).Item(0) & ">" &
ds.Tables(0).Rows(i).Item(0) & " </a>"
tr.Cells.Add(tc)
Table1.Rows.Add(tr)
Next
End Sub
End Class
Default2.aspx
code
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled
Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:GridView ID="GridView1" runat="server" BackColor="#FF9999">
<HeaderStyle BackColor="#FFCC99" />
</asp:GridView>
</form>
</body>
</html>
Default2.aspx.vb code
Imports
System.Data.SqlClient
Imports
System.Data
Partial Class Default2
Inherits System.Web.UI.Page
Dim strConnString As String =
System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ToString()
Dim sqlda As
SqlDataAdapter
Dim com As
SqlCommand
Dim ds As
DataSet
Dim dt As
DataTable
Dim str As String
Dim con As New SqlConnection(strConnString)
Protected Sub
Page_Load(ByVal sender
As Object, ByVal
e As System.EventArgs)
Handles Me.Load
con.open()
Str =
"select * from student where sid='" &
Request.QueryString("id") &
"'"
com =
New SqlCommand(Str, con)
sqlda =
New SqlDataAdapter(com)
ds =
New DataSet
ds.Clear()
ds.Reset()
sqlda.Fill(ds,
"student")
GridView1.DataMember = "student"
GridView1.DataSource = ds
GridView1.DataBind()
con.Close()
End Sub
End Class
Output


Thanks for
reading.