通过这个网页,我想让用户创建问题,这样他就可以用其选项编写问题并指定正确的答案。 问题是当我选择正确答案(单选按钮)时,我无法获得单选按钮的值
protected void btnSubmit_Click(object sender, EventArgs e)
{
string sQsnDesc = "", sCorrectOptn = "", sOptns = "", stxtOption = "", sResult = "";
sQsnDesc = txtQsnDesc.Text.ToString().Trim().Replace("\r\n", "<br>");
if (btnSubmit.Text == "Submit")
{
sOptns = ddlOptions.SelectedValue.ToString().Trim();
if (rbtnOpt1.Checked == true)
{
sCorrectOptn = "Option1";
}
else if (rbtnOpt2.Checked == true)
{
sCorrectOptn = "Option2";
}
else if (rbtnOpt3.Checked == true)
{
sCorrectOptn = "Option3";
}
else if (rbtnOpt4.Checked == true)
{
sCorrectOptn = "Option4";
}
else if (rbtnOpt5.Checked == true)
{
sCorrectOptn = "Option5";
}
sResult = SqlHelper.ExecuteNonQueryOutput(sCon, "PS_Quiz_QsnCreationMaster_Insert", sQsnDesc, sOptns, sCorrectOptn, txtMarks.Text, Session["LogInId"].ToString(), null);
当我尝试插入数据时,它表示“无法插入空值
”你可以在这里查看代码 https://docs.google.com/file/d/0B2BDZn7hHcrwZG9SQnhKMG1rcE0 https://docs.google.com/file/d/0B2BDZn7hHcrwbUlZdmNxNzVWek0
**抱歉,我无法插入孔码,实际上这是我第一次在这个网站上发帖。
答案 0 :(得分:0)
这是asp.net吗?您是否需要使用.findcontrol方法来检查您的radiobuttons的属性(在本例中为.checked)?