Avatar of ITsolutionWizard
ITsolutionWizard
Flag for United States of America

asked on 

c#, case, if

Below codes in c#. how can I use CASE instead?
The goal is to shorten the codes....

Thanks
DropDownList selectedInsuranceProductType = (DropDownList)InsuranceTypesList.FindControl("insuranceProductsList");
            if (selectedInsuranceProductType.SelectedValue == "Health")
            {
                panelHealth.Visible = true;
            }
            else if (selectedInsuranceProductType.SelectedValue == "Life")
            {
                panelLife.Visible = true;
            }
            else if (selectedInsuranceProductType.SelectedValue == "Accident")
            {
                panelAccident.Visible = true;
            }
            else if (selectedInsuranceProductType.SelectedValue == "Dental")
            {
                panelDental.Visible = true;
            }
            else
            {
                panelHealth.Visible = false;
                panelLife.Visible = false;
            }

Open in new window

.NET ProgrammingC#

Avatar of undefined
Last Comment
Nitin Sontakke

8/22/2022 - Mon