Hi nsds,
Please refer below sample.
HTML
<asp:Button ID="btnSave" Text="Save" runat="server" OnClick="Save" />
Home
Defualt
Student ID:
<asp:Label ID="lblPage" runat="server" /><br />
Department ID:
<asp:Label ID="lblName" runat="server" />
Code
C#
private int student_id = 1;
private int dept_id = 1;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
student_id = Convert.ToInt32(Session["selected_student_id"]);
dept_id = GetDeptID(student_id);
}
}
protected void Save(object sender, EventArgs e)
{
Session["selected_studentID"] = student_id;
Session["selected_DEPT_ID"] = dept_id;
Response.Redirect("Home.aspx");
}
private int GetDeptID(int id)
{
id = dept_id;
return id;
}
Home
Defualt
protected void Page_Load(object sender, EventArgs e)
{
lblPage.Text = Session["selected_studentID"].ToString();
lblName.Text = Session["selected_DEPT_ID"].ToString();
}
VB.Net
Private student_id As Integer = 1
Private dept_id As Integer = 1
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
student_id = Convert.ToInt32(Session("selected_student_id"))
dept_id = GetDeptID(student_id)
End If
End Sub
Protected Sub Save(ByVal sender As Object, ByVal e As EventArgs)
Session("selected_studentID") = student_id
Session("selected_DEPT_ID") = dept_id
Response.Redirect("HomeVB.aspx")
End Sub
Private Function GetDeptID(ByVal id As Integer) As Integer
id = dept_id
Return id
End Function
VB.Net
Defualt
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
lblPage.Text = Session("selected_studentID").ToString()
lblName.Text = Session("selected_DEPT_ID").ToString()
End Sub
Screenshot