Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 当用户选择下拉列表时填充标签_C#_Asp.net - Fatal编程技术网

C# 当用户选择下拉列表时填充标签

C# 当用户选择下拉列表时填充标签,c#,asp.net,C#,Asp.net,我想知道当用户选择给出年份和月份的两个下拉列表时,如何填充标签集?不确定“一组标签”是什么意思,但如果您只需要组合框值,类似这样的功能就可以了 label1.Text = comboBox1.SelectedValue + "/" + comboBox2.SelectedValue; 将两个DropDownList项目的SelectedIndexChanged设置到下面 protected void DropDownList_SelectedIndexChanged(object se

我想知道当用户选择给出年份和月份的两个下拉列表时,如何填充标签集?

不确定“一组标签”是什么意思,但如果您只需要组合框值,类似这样的功能就可以了

label1.Text = comboBox1.SelectedValue + "/" + comboBox2.SelectedValue;

将两个
DropDownList
项目的
SelectedIndexChanged
设置到下面

    protected void DropDownList_SelectedIndexChanged(object sender, EventArgs e)
    {
        Label1.Text = string.Format("Year :{0}, Month :{1}" , DropDownListYear.SelectedValue, DropDownListMonth.SelectedValue);
    }

有一个名为SelectedIndexChanged的事件用于DropDownList。您可以使用它来填充标签集。因为这里有两个Dorpdown,所以您可以执行以下操作:

    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";

    }

可能是对问题的更恰当的描述,一些代码会有所帮助。您是如何在下拉列表中指定月份和年份的格式的?标签上是否有任何特定的显示格式?