I found out the problem and solution for this: The problem is Session["choice"] = Null and it is not acceptable under MSN standard. So I need to add this to prevent Null value :
if ((string)Session["choice"] == null)
{
cmdIns.Parameters.Add("@Choice", SqlDbType.NVarChar).Value = DBNull.Value;
}
else
{
// cmdIns.Parameters.AddWithValue("@Choice", (string)Session["choice"]);
cmdIns.Parameters.Add("@Choice", SqlDbType.NVarChar).Value = (string)Session["choice"];
}
To fix the null value, in .aspx file(I still can't figure out why the old code give null, but this one can avoid it)
<div>
<asp:RadioButton ID="RadioButton1" GroupName="Group1" Text="Choice 1" OnCheckedChanged="Button1_Click" AutoPostBack="true" runat="server" />
<asp:RadioButton ID="RadioButton2" GroupName="Group1" Text="Choice 2" OnCheckedChanged="Button1_Click" AutoPostBack="true" runat="server" />
<asp:RadioButton ID="RadioButton3" GroupName="Group1" Text="Choice 3" OnCheckedChanged="Button1_Click" AutoPostBack="true" runat="server" />
</div>
and .cs file:
protected void Button1_Click(object sender, System.EventArgs e)
{
// Session["choice"] = RadioButtonList1.SelectedItem.Text;
if (RadioButton1.Checked)
{
Session["choice"] = "Choice 1";
}
if (RadioButton2.Checked)
{
Session["choice"] = "Choice 2";
}
if (RadioButton3.Checked)
{
Session["choice"] = "Choice 3";
}
}