オブジェクトタイプ(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();
}
次にヒットしたときにデータベースに応答を挿入するメソッドを作成するにはどうすればよいですか? どんなアイデアでも感謝します
ありがとう