当用户选择下拉列表时填充标签
本文关键字:填充 标签 下拉列表 用户 选择 | 更新日期: 2023-09-27 18:30:07
我想知道当用户选择两个下拉列表时,如何填写一组标签,其中给出年份和月份?
将两个DropDownList
项目的SelectedIndexChanged
设置为低于
protected void DropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
Label1.Text = string.Format("Year :{0}, Month :{1}" , DropDownListYear.SelectedValue, DropDownListMonth.SelectedValue);
}
有一个名为DropDownList的事件,SelectedIndexChanged。您可以使用它来填充您的标签集。既然你在这里有两个仓库,你必须做一些类似的事情:
protected void DropDownYear_SelectedIndexChanged(object sender, EventArgs e)
{
/* code to check if the user has selected the year */
label1.Text = "your string";
label2.Text = "your other string";
}
不确定"标签集"是什么意思,但如果你只想要combobox值,这样的东西会起作用。
label1.Text = comboBox1.SelectedValue + "/" + comboBox2.SelectedValue;