Disable/remove value in dropdown menu after being selected

后端 未结 1 794
无人共我
无人共我 2021-01-28 21:03

Just wanna ask u guys for help. I have this dropdown menu in my abc.aspx page. There, user will choose month and enter the expenses and prices in the textbox provided. It will b

相关标签:
1条回答
  • 2021-01-28 21:33

    Why not try the following:

    ASPX

    <asp:DropDownList ID="DropDownList1" runat="server" Font-Bold="True" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
        <asp:ListItem Text="Please choose" Value=""></asp:ListItem>
        <asp:ListItem Text="January" Value="January"></asp:ListItem>
        <asp:ListItem Text="February" Value="February"></asp:ListItem>
        <asp:ListItem Text="March" Value="March"></asp:ListItem>
    </asp:DropDownList>
    

    C#

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Session["Month"] != null)
            {
                if (DropDownList1.SelectedValue == Session["Month"])
                {
                    DropDownList1.SelectedValue = string.Empty;
                }
                else
                {
                    Session["Month"] = DropDownList1.SelectedValue;
                }
            }
        }
    

    Make this is the ASPX and C# on your first page.

    0 讨论(0)
提交回复
热议问题