Hi Indradeo,
Kindly follow below sample.
HTML
Page-1
<table>
<tr>
<td>Name:</td>
<td>
<asp:TextBox runat="server" ID="txtName"></asp:TextBox></td>
</tr>
<tr>
<td>Employee Id:</td>
<td>
<asp:TextBox runat="server" ID="txtEmpId"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Button runat="server" ID="btnSend" Text="Send" OnClick="OnSend" /></td>
</tr>
</table>
Page-2
<table>
<tr>
<td>Name:</td>
<td>
<asp:Label runat="server" ID="lblName"></asp:Label></td>
</tr>
<tr>
<td>Employee Id:</td>
<td>
<asp:Label runat="server" ID="lblEmpId"></asp:Label></td>
</tr>
<tr>
<td>
<asp:Button runat="server" ID="btnSend" Text="Send" /></td>
</tr>
</table>
Namespaces
using System.Configuration;
using System.Data.SqlClient;
Code
Page-1
protected void OnSend (object sender, EventArgs e)
{
Response.Redirect("Page-2.aspx?Name=" + txtName.Text + "&EmployeeId=" + txtEmpId.Text);
}
Page-2
protected void Page_Load(object sender, EventArgs e)
{
string name = Request.QueryString["Name"];
string employeeId = Request.QueryString["EmployeeId"];
lblName.Text = name;
lblEmpId.Text = employeeId;
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("INSERT INTO Details (Name,Id) VALUES (@Name,@Id)"))
{
cmd.Parameters.AddWithValue("@Name", name);
cmd.Parameters.AddWithValue("@Id", employeeId);
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}