VS里面Listbox怎么实现选中一项,在textbox里显示相应的内容?也就是Listbox怎么把值传递出来?
展开全部
<asp:ListBox ID="ListBox1" runat="server" AutoPostBack="True"
onselectedindexchanged="ListBox1_SelectedIndexChanged">
<asp:ListItem>测试</asp:ListItem>
<asp:ListItem>测试2</asp:ListItem>
</asp:ListBox>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
后台代码:
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (ListBox1.SelectedValue!=null)
{
TextBox1.Text = ListBox1.SelectedValue;
}
}
onselectedindexchanged="ListBox1_SelectedIndexChanged">
<asp:ListItem>测试</asp:ListItem>
<asp:ListItem>测试2</asp:ListItem>
</asp:ListBox>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
后台代码:
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (ListBox1.SelectedValue!=null)
{
TextBox1.Text = ListBox1.SelectedValue;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询