I am trying to pass a control as a session variable to a new page.
In the new page, the value of the control is added as a paramneter to an sql command.
This seems to work with textboxes, but not checkboxes.
in the passing page I have:
....
Session["MyTextBox"] = Request["MyTextBox"];
Session["MyCheckBox"] = Request["MyCheckBox"];
...
It is passed to a new page using:
Response.Redirect("NewPage.aspx", true);
In the new page I have
p = new SqlParameter("@MyTextBox", SqlDbType.VarChar, 10, "MyTextBox");
p.Value = Session["MyTextBox"];
cmd.Parameters.Add(p);
p = new SqlParameter("@MyCheckBox", SqlDbType.Bit, 1, "MyCheckBox");
p.Value = Session["Convert.ToBoolean(MyCheckBox)"];
cmd.Parameters.Add(p);
The TextBox works fine.
The checkbox does not trow an error, but I do not seem to be getting the boolean value in the parameters. The result acts as if the value is false, even when the passed checkbox is checked.
Any ideas?
In the new page, the value of the control is added as a paramneter to an sql command.
This seems to work with textboxes, but not checkboxes.
in the passing page I have:
....
Session["MyTextBox"] = Request["MyTextBox"];
Session["MyCheckBox"] = Request["MyCheckBox"];
...
It is passed to a new page using:
Response.Redirect("NewPage.aspx", true);
In the new page I have
p = new SqlParameter("@MyTextBox", SqlDbType.VarChar, 10, "MyTextBox");
p.Value = Session["MyTextBox"];
cmd.Parameters.Add(p);
p = new SqlParameter("@MyCheckBox", SqlDbType.Bit, 1, "MyCheckBox");
p.Value = Session["Convert.ToBoolean(MyCheckBox)"];
cmd.Parameters.Add(p);
The TextBox works fine.
The checkbox does not trow an error, but I do not seem to be getting the boolean value in the parameters. The result acts as if the value is false, even when the passed checkbox is checked.
Any ideas?