我正在做一個迷你測驗,我被困在C#編碼中,檢查用戶從DropDownList中選擇哪個ListItem。如何檢查ListItem是否被選中?
<li><b>What is 231 mod 55?</b>
<asp:Label ID="lblQuestionResult2" runat="server" Font-Bold="true" Font-Size="16px" />
<br />
<asp:DropDownList ID="DropDownList1" runat="server" Width="55px">
<asp:ListItem>14</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>11</asp:ListItem>
</asp:DropDownList>
</li>
我沒有工作。如何去檢查用戶選擇的內容?
if (ListItem.Equals(toString(11)))
{
lblQuestionResult2.ForeColor = System.Drawing.Color.Green;
lblQuestionResult2.Text = "Correct";
}
else
{
lblQuestionResult2.ForeColor = System.Drawing.Color.Red;
lblQuestionResult2.Text = "Incorrect";
}
檢查這一個out.http://stackoverflow.com/questions/1829935/get-all-selected-items-from-asp-net-listbox – 2013-03-04 06:17:15