這裏是C#文件代碼,我希望每個輸出都能得到單選按鈕,這樣我就可以像在「mcqs」中那樣選擇選項。單選按鈕通過C#文件中的內部html返回答案選擇
public HtmlString questions_sec1()
{
int userid = Convert.ToInt32(Session["USERID"]);
List<DAO_getQuestiones> get_question_sec1 = new List<DAO_getQuestiones>(DAO_getQuestiones.get_question_sec1(userid)); // data to fech first section
string content = "";
HtmlString theEnvelopePlease = null;
try
{
foreach (var obj in get_question_sec1)
{
content = content + "<tr><td> " + obj.get_question_id + "</td> <td>" + obj.get_answer_question + "</td><td>"+ <input type="radio" name="d" value="data"> DATA +"</td></tr>";
}
theEnvelopePlease = new HtmlString(content);
return theEnvelopePlease;
}
catch (Exception ex)
{
content = content + ex;
theEnvelopePlease = new HtmlString(content);
return theEnvelopePlease;
}
}
這裏是HTML呼叫時,返回CS文件的功能渲染代碼:
<table>
<thead>
<tr>
<th>Sr.</th>
<th>Questions</th>
<th>Answers</th>
</tr>
</thead>
<tbody>
< %:questions_sec1() % >
</tbody>
</table>
問:我想單選按鈕,每出答案看跌,這樣我可以選擇一個選項和一件事。
我建議你看看[RadioButtonList Control](https://msdn.microsoft.com/en-us/library/cc295394.aspx)。 – VDWWD