write this code in 1st page
DEFAULT.ASP
<div>
<a href="ShowDetails.aspx?autoid=5" title="Show records where AutoId is 5">Show records where AutoId is 5 </a>
<p><asp:HyperLink ID="hyper1" runat="server" Text="Show Record where AutoID is 8"> </asp:HyperLink> </p>
</div>
DEFAULT.ASPX.CS CODE BEHIND
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
hyper1.NavigateUrl = "ShowDetails.aspx?autoid=8&com=show";
}
}
SHOWDETAILS.ASPX
<div>
<asp:DetailsView ID="DetailsView1" runat="server" EnableViewState="false" />
</div>
SHOWDETAILS.ASPX.CS CODE BEHIND
rotected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (!string.IsNullOrWhiteSpace(Request.QueryString["autoid"]))
{
int autoId = 0;
int.TryParse(Request.QueryString["autoid"], out autoId);
if (!autoId.Equals(0))
{
GetData(autoId);
}
}
string command = Request.QueryString["com"];
}
}
private void GetData(int autoId)
{
DataTable table = new DataTable();
using (SqlConnection conn = new SqlConnection(_connStr))
{
string sql = "SELECT AutoId, FirstName, LastName, Age, Active FROM PersonalDetail WHERE AutoId = @AutoId ORDER By AutoId";
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
using (SqlDataAdapter ad = new SqlDataAdapter(cmd))
{
SqlParameter prm = new SqlParameter("@AutoId", SqlDbType.Int);
prm.Value = autoId;
cmd.Parameters.Add(prm);
ad.Fill(table);
}
}
}
DetailsView1.DataSource = table;
DetailsView1.DataBind();
}