这是我的代码,它根据对象类型(droprdown、checkbox、radioutton ..)从 db 表中填充问题
if (str.Trim().ToLower() == "dropdown box")
{
string[] strArr = strOptions.Split('|');
DropDownList ddl = new DropDownList();
ddl.ID = "ddl";
ddl.CssClass = "CheckBox";
ddl.Width = Unit.Pixel(100);
// ddl.Items.Add(new ListItem("test", "test"));
if (strArr.Count() > 0)
{
foreach (string s in strArr)
{
ddl.Items.Add(new ListItem(s, s));
}
}
else
{
ddl = new DropDownList();
ddl.ID = "ddlContent1";
ddl.Width = Unit.Pixel(150);
plc.Controls.Add(ddl);
}
plc.Controls.Add(ddl);
}
if (str.Trim().ToLower() == "checkbox list")
{
string[] strArr = strOptions.Split('|');
if (strArr.Count() > 0)
{
foreach (string s in strArr)
{
CheckBox chk = new CheckBox();
chk.ID = s;
chk.Text = s;
chk.CssClass = "CheckBox";
if (strFooterOptions == "If all of the above are checked, please SUBMIT. [Click here to Submit]")
chk.Attributes.Add("onclick", "checkAllCheckBox()");
plc.Controls.Add(chk);
plc.Controls.Add(new LiteralControl("<br />"));
}
}
还有我的上一个和下一个按钮,当你点击下一个时,它会在其他部分显示另一个问题。
protected void btnNext_Click(object sender, EventArgs e)
{
// int section = 1;
section = section + 1;
btnPrev.Enabled = true;
FillSection();
}
protected void btnPrev_Click(object sender, EventArgs e)
{
section = section - 1;
FillSection();
}
当我点击下一步时,如何创建一种方法来插入对数据库的响应?任何想法欣赏
谢谢