title: Generic way to implement if else statement
body: <p>I have got  lots of if-else statements inside dropdown list selected change event  for populating another dropdownlist based on value select in current drop downlist..
  Is there any generic way to reduce this much of if-else statements with any parameter type..
  and this is my code for  drop down list selected change event </p>
  
  <pre><code>protected void ddlBr1Type_SelectedIndexChanged(object sender, EventArgs e)
  {
        if (ddlBr1Type.SelectedValue.ToString() == ValidationFields.FO.ToString())
        {
             ddlBr2Type.DataSource = populateNearByDropdown(ValidationFields.FO.ToString());
             ddlBr2Type.DataBind();
        }
        else if (ddlBr1Type.SelectedValue.ToString() == ValidationFields.FW.ToString())
        {
            ddlBr2Type.DataSource = populateNearByDropdown(ValidationFields.FW.ToString());
              ddlBr2Type.DataBind();
  
       }
       else if (ddlBr1Type.SelectedValue.ToString() == ValidationFields.UF.ToString())
       {
            ddlBr2Type.DataSource = populateNearByDropdown(ValidationFields.UF.ToString());
              ddlBr2Type.DataBind();
       }
       else if (ddlBr1Type.SelectedValue.ToString() == ValidationTypes.O.ToString())
       {
           ddlBr2Type.DataSource = populateNearByDropdown(ValidationTypes.O.ToString());
              ddlBr2Type.DataBind();
       }
       else if (ddlBr1Type.SelectedValue.ToString() == ValidationTypes.W.ToString())
       {
            ddlBr2Type.DataSource = populateNearByDropdown(ValidationTypes.W.ToString());
              ddlBr2Type.DataBind();
       }
       else if (ddlBr1Type.SelectedValue.ToString() == ValidationTypes.P.ToString())
       {
            ddlBr2Type.DataSource = populateNearByDropdown(ValidationTypes.P.ToString());
              ddlBr2Type.DataBind();
       }
       else if (ddlBr1Type.SelectedValue.ToString() == ValidationTypes.C.ToString())
       {
              ddlBr2Type.DataSource = populateNearByDropdown(ValidationTypes.C.ToString());
              ddlBr2Type.DataBind();
        }
  
    }
  </code></pre>
  
  <p>here ValidationTypes and validationfields are an enumlists and this is code for PopulateNearbyDropdown method</p>
  
  <pre><code>   private List&lt;string&gt; populateNearByDropdown(String Item1)
      {
          var MatchedItems =  new List&lt;string&gt;();
          var listofitems = new List&lt;string&gt; { "FO", "FW", "O", "W", "UF" };
          if (listofitems.Any(str =&gt; str.Contains(Item1)))
          {
              MatchedItems = new List&lt;string&gt; { Item1, ValidationTypes.P.ToString(), ValidationTypes.C.ToString() };
          }
          else if (Item1 == "P")
          {
              MatchedItems = new List&lt;string&gt; { Item1, ValidationTypes.C.ToString() };            
          }
          else if (Item1 == "C")
          {
              MatchedItems = new List&lt;string&gt; { Item1, ValidationTypes.U.ToString() };
          }
          else if (Item1 == "U"  || Item1 == "FC")
          {
              MatchedItems = new List&lt;string&gt; { Item1 };
  
          }
          return MatchedItems.ToList();
      }
  </code></pre>
  
  <p>would any one pls help on this..
  Many thanks In advance... </p>