前台代码:<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="1">哈哈</asp:ListItem>
<asp:ListItem Value="2">吼吼</asp:ListItem>
</asp:DropDownList>
</form>
后台代码:protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (DropDownList1.Items[0].Selected == true)
{
TextBox1.Text = DropDownList1.Items[1].Value;
}
else
{
TextBox1.Text = DropDownList1.Items[0].Value;
}
}
}
当列表框里的内容从新选时,前面的文本框里的内容不变化
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
TextBox1.Text = DropDownList1.SelectedValue ;
}本回答被提问者和网友采纳