I have a session variable stored from when a User logs into the web app. Then the logged in user can store information. When this information stores the Session Variable(UserId) doubles itself
for example if the user ID is 1 it saves as 11 or if it should be 4 it saves as 44.
Any ideas why this might be the case.
I have the session variable saved into a label on the form when the page loads:
//show label with corresponding Name used in log in
UserID.Text += Session["UserId"].ToString();
This is my code behind the save button:
- protected void AddBooking_Click(object sender, EventArgs e)
- {
-
- string cs = ConfigurationManager.ConnectionStrings["BookingDb"].ConnectionString;
- SqlConnection con = new SqlConnection(cs);
-
- SqlCommand cmd = new SqlCommand("[dbo].[spAddBooking]", con);
- cmd.CommandType = CommandType.StoredProcedure;
- try
- {
- cmd.Parameters.AddWithValue("@UserId", UserID.Text.Trim());
- cmd.Parameters.AddWithValue("@MemberType", ddlMemberType.SelectedValue);
- cmd.Parameters.AddWithValue("@PitchSection", ddlSyntheticPitch.SelectedValue);
- cmd.Parameters.AddWithValue("@Date", txtDate.Text.Trim());
- cmd.Parameters.AddWithValue("@StartTime", ddlStartTime.SelectedValue);
- cmd.Parameters.AddWithValue("@EndTime", ddlEndTime.SelectedValue);
- cmd.Parameters.AddWithValue("@Description", txtDescription.InnerText.Trim());
- con.Open();
- cmd.ExecuteNonQuery();
- }
- catch (Exception ex)
- {
- Response.Write(ex);
- }
- finally
- {
- con.Close();
- Response.Redirect("BookingForm.aspx");
- }