Hi indradeo,
Please check this sample. now take its reference.
HTML
Page1.aspx
Enter Name :
<asp:TextBox ID="txtName" runat="server" autocomplete="off" /><br />
Enter Country :
<asp:TextBox ID="txtCountry" runat="server" autocomplete="off" /><br /><br />
<asp:Button ID="btnsubmit" Text="Submit" runat="server" OnClick="OnSubmit" />
Details.aspx
<asp:GridView ID="gvDetails" runat="server">
</asp:GridView>
Namespaces
C#
using System;
using System.Data;
VB.Net
Imports System
Imports System.Data
Code
C#
page1.cs
protected void OnSubmit(object sender, EventArgs e)
{
string name = txtName.Text.Trim();
string country = txtCountry.Text.Trim();
Response.Redirect("Details.aspx?Name=" + name + "&Country=" + country);
}
Details.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
if (Request.QueryString["Name"] != "" && Request.QueryString["Country"] != "")
{
string name = Request.QueryString["Name"];
string country = Request.QueryString["Country"];
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dt.Columns.Add("Country");
dt.Rows.Add(name, country);
this.gvDetails.DataSource = dt;
this.gvDetails.DataBind();
}
}
}
VB.Net
page1.aspx.vb
Protected Sub OnSubmit(ByVal sender As Object, ByVal e As EventArgs)
Dim name As String = txtName.Text.Trim()
Dim country As String = txtCountry.Text.Trim()
Response.Redirect("Details.aspx?Name=" & name & "&Country=" & country)
End Sub
Details.aspx.vb
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
If Request.QueryString("Name") <> "" AndAlso Request.QueryString("Country") <> "" Then
Dim name As String = Request.QueryString("Name")
Dim country As String = Request.QueryString("Country")
Dim dt As DataTable = New DataTable()
dt.Columns.Add("Name")
dt.Columns.Add("Country")
dt.Rows.Add(name, country)
Me.gvDetails.DataSource = dt
Me.gvDetails.DataBind()
End If
End If
End Sub
Screenshot