,NET怎么把radiobuttonlist和checkboxlist选择的结果输出到一个文本框显示
1个回答
展开全部
<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Value="男"></asp:ListItem>
<asp:ListItem Value="女"></asp:ListItem>
</asp:RadioButtonList>
<asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Value="上网"></asp:ListItem>
<asp:ListItem Value="打球"></asp:ListItem>
<asp:ListItem Value="看电影"></asp:ListItem>
</asp:CheckBoxList>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<br />
<asp:TextBox ID="TextBox1" runat="server" Height="107px" TextMode="MultiLine"
Width="267px"></asp:TextBox>
后台 protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = "你的性别为" + RadioButtonList1.SelectedValue + "\n";
string str="";
foreach (ListItem listItem in CheckBoxList1.Items)
{
if (listItem.Selected)
{
str+=listItem.Value;
}
}
TextBox1.Text += "你的爱好为" + str + "\n";
}
<asp:ListItem Value="男"></asp:ListItem>
<asp:ListItem Value="女"></asp:ListItem>
</asp:RadioButtonList>
<asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Value="上网"></asp:ListItem>
<asp:ListItem Value="打球"></asp:ListItem>
<asp:ListItem Value="看电影"></asp:ListItem>
</asp:CheckBoxList>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<br />
<asp:TextBox ID="TextBox1" runat="server" Height="107px" TextMode="MultiLine"
Width="267px"></asp:TextBox>
后台 protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = "你的性别为" + RadioButtonList1.SelectedValue + "\n";
string str="";
foreach (ListItem listItem in CheckBoxList1.Items)
{
if (listItem.Selected)
{
str+=listItem.Value;
}
}
TextBox1.Text += "你的爱好为" + str + "\n";
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询