因此,我有此复选框列表,并且在选中了MISC复选框时,我试图生成文本框。
<asp:CheckBoxList ID="chbxEquipmnt" runat="server"RepeatColumns="4" RepeatDirection="Horizontal" ValidationGroup="Equipment" OnSelectedIndexChanged="chbxEquipmnt_SelectedIndexChanged">
<asp:ListItem Value="Laptop">Laptop</asp:ListItem>
<asp:ListItem Value=" Label Printer">Label Printer</asp:ListItem>
<asp:ListItem Value="Printer">Printer</asp:ListItem>
<asp:ListItem Value="Fax Line">Fax Line</asp:ListItem>
<asp:ListItem Value="PC">PC</asp:ListItem>
<asp:ListItem Value="MFD">MFD</asp:ListItem>
<asp:ListItem Value="Phone Line">Phone Line</asp:ListItem>
<asp:ListItem Value="Misc">Misc</asp:ListItem>
</asp:CheckBoxList>
在我的 Cs 页面上,我有…………
protected void chbxEquipmnt_SelectedIndexChanged(object sender, EventArgs e)
{
if (chbxEquipmnt.SelectedValue == "Misc")
{
TextBox txt = new TextBox();
txt.ID = "txtMiscCheckBox";
Page.Form.Controls.Add(txt);
}
}
调试我已经尝试过回发,它不断返回第一个选中的复选框......例如,我首先检查了笔记本电脑而不是杂项,调试器中的值总是显示我的笔记本电脑。我不确定通过所有按钮单击的简单循环是否会有所帮助.....我刚从学校毕业,这对我来说是职业转变,所以感谢您的耐心