I have few controls on my page which I want to show/hide and/or enable/disable on some condition.Images to help illustrate the requirements:Following is the code to show/hide, enable/disable the controls. Please review it and tell me how I can extract common code.Any other suggestion are also more than welcome.// Change controls status (enable/disable, show/hide) on the basis of selected itemprotected void ddlLocationType_SelectedIndexChanged(object sender, EventArgs e){    int locationType = 0;    int.TryParse(ddlLocationType.SelectedItem.Value, out locationType);    EnableRelavantLocaitonControls(locationType);}private void EnableRelavantLocaitonControls(int locationType){    switch (locationType)    {    case 0:        DefaultControlsPosition();        break;    case 1:        EnableControlsForProvince();        break;    case 2:        EnableControlsForDistrict();        break;    case 3:        EnableControlsForTehsil();        break;    case 4:        EnableControlsForUC();        break;    case 6:        EnableControlsForVillage();        break;    default:        DefaultControlsPosition();        break;    }}// Show all drop downs.// Hide all textboxes and disable all controls.private void DefaultControlsPosition(){    ddlProvince.Enabled = false;    ddlProvince.Visible = true;    txtProvince.Enabled = false;    txtProvince.Visible = false;    ddlDistrict.Enabled = false;    ddlDistrict.Visible = true;    ddlDistrict.Enabled = false;    txtDistrict.Visible = false;    ddlTehsil.Enabled = false;    ddlTehsil.Visible = true;    txtTehsil.Enabled = false;    txtTehsil.Visible = false;    ddlUC.Enabled = false;    ddlUC.Visible = true;    txtUC.Enabled = false;    txtUC.Visible = false;    ddlVillage.Enabled = false;    ddlVillage.Visible = true;    txtVillage.Enabled = false;    txtVillage.Visible = false;}// Show all drop downs except province drop down and disable all.// Show and enable TextBox for province instead of drop down so user can // enter name of province.private void EnableControlsForProvince(){    ddlProvince.Enabled = false;    ddlProvince.Visible = false;    txtProvince.Enabled = true;    txtProvince.Visible = true;    ddlDistrict.Enabled = false;    ddlDistrict.Visible = true;    ddlDistrict.Enabled = false;    txtDistrict.Visible = false;    ddlTehsil.Enabled = false;    ddlTehsil.Visible = true;    txtTehsil.Enabled = false;    txtTehsil.Visible = false;    ddlUC.Enabled = false;    ddlUC.Visible = true;    txtUC.Enabled = false;    txtUC.Visible = false;    ddlVillage.Enabled = false;    ddlVillage.Visible = true;    txtVillage.Enabled = false;    txtVillage.Visible = false;}// Show and Enable 'Province' drop down.// Hide and Disable 'District' drop down.// Show and Enable 'District' text box.// Show and Disable all other drop downs beneath District.private void EnableControlsForDistrict(){    ddlProvince.Enabled = true;    ddlProvince.Visible = true;    txtProvince.Enabled = false;    txtProvince.Visible = false;    ddlDistrict.Enabled = false;    ddlDistrict.Visible = false;    txtDistrict.Enabled = true;    txtDistrict.Visible = true;    ddlTehsil.Enabled = false;    ddlTehsil.Visible = true;    txtTehsil.Enabled = false;    txtTehsil.Visible = false;    ddlUC.Enabled = false;    ddlUC.Visible = true;    txtUC.Enabled = false;    txtUC.Visible = false;    ddlVillage.Enabled = false;    ddlVillage.Visible = true;    txtVillage.Enabled = false;    txtVillage.Visible = false;}private void EnableControlsForTehsil(){    ddlProvince.Enabled = true;    ddlProvince.Visible = true;    txtProvince.Enabled = false;    txtProvince.Visible = false;    ddlDistrict.Enabled = true;    ddlDistrict.Visible = true;    txtDistrict.Enabled = false;    txtDistrict.Visible = false;    ddlTehsil.Enabled = false;    ddlTehsil.Visible = false;    txtTehsil.Enabled = true;    txtTehsil.Visible = true;    ddlUC.Enabled = false;    ddlUC.Visible = true;    txtUC.Enabled = false;    txtUC.Visible = false;    ddlVillage.Enabled = false;    ddlVillage.Visible = true;    txtVillage.Enabled = false;    txtVillage.Visible = false;}private void EnableControlsForUC(){    ddlProvince.Enabled = true;    ddlProvince.Visible = true;    txtProvince.Enabled = false;    txtProvince.Visible = false;    ddlDistrict.Enabled = true;    ddlDistrict.Visible = true;    txtDistrict.Enabled = false;    txtDistrict.Visible = false;    ddlTehsil.Enabled = true;    ddlTehsil.Visible = true;    txtTehsil.Enabled = false;    txtTehsil.Visible = false;    ddlUC.Enabled = false;    ddlUC.Visible = false;    txtUC.Enabled = true;    txtUC.Visible = true;    ddlVillage.Enabled = false;    ddlVillage.Visible = true;    txtVillage.Enabled = false;    txtVillage.Visible = false;}private void EnableControlsForVillage(){    ddlProvince.Enabled = true;    ddlProvince.Visible = true;    txtProvince.Enabled = false;    txtProvince.Visible = false;    ddlDistrict.Enabled = true;    ddlDistrict.Visible = true;    txtDistrict.Enabled = false;    txtDistrict.Visible = false;    ddlTehsil.Enabled = true;    ddlTehsil.Visible = true;    txtTehsil.Enabled = false;    txtTehsil.Visible = false;    ddlUC.Enabled = true;    ddlUC.Visible = true;    txtUC.Enabled = false;    txtUC.Visible = false;    ddlVillage.Enabled = false;    ddlVillage.Visible = false;    txtVillage.Enabled = true;    txtVillage.Visible = true;}
Extract common code to enable/disable, show/hide controls on some condition
c#