Created
December 8, 2016 05:04
-
-
Save ssbalakumar/7b18b282cd3d239f624bf10b1b1f71f8 to your computer and use it in GitHub Desktop.
Cascading Dropdown Edit Mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void Edit(object sender, EventArgs e) | |
{ | |
hfAddEditId.Value = (sender as Button).CommandArgument; | |
_HrmEntity.intDistrictId = Convert.ToInt32(hfAddEditId.Value); | |
List<Entity_HRM> listdist = new List<Entity_HRM>(); | |
listdist = _district.GetAllDataById(_HrmEntity); | |
var sta = (from usr in listdist select usr); | |
if (sta.Any()) | |
{ | |
List<Entity_HRM> listCountry = new List<Entity_HRM>(); | |
listCountry = _country.GetAll(); | |
var con = (from usr in listCountry select usr); | |
if (con.Any()) | |
{ | |
ddlCountry.DataSource = _country.GetAll(); | |
ddlCountry.DataTextField = "varCountryName"; | |
ddlCountry.DataValueField = "intCountryId"; | |
ddlCountry.DataBind(); | |
ddlCountry.Items.Insert(0, new ListItem("--- Select Country ---", "")); | |
ddlCountry.SelectedIndex = Convert.ToInt32(sta.Single().intCountryId.ToString()); | |
} | |
List<Entity_HRM> listState = new List<Entity_HRM>(); | |
listState = _country.GetAll(); | |
var st = (from usr in listCountry select usr); | |
if (con.Any()) | |
{ | |
_HrmEntity.intCountryId = Convert.ToInt32(sta.Single().intCountryId.ToString()); | |
ddlState.DataSource = _state.GetAllDataByCountryId(_HrmEntity); | |
ddlState.DataTextField = "varStateName"; | |
ddlState.DataValueField = "intStateId"; | |
ddlState.DataBind(); | |
ddlState.SelectedValue = sta.Single().intStateId.ToString(); | |
ddlState.Items.Insert(0, new ListItem("--- Select State ---", "")); | |
} | |
txtDistrict.Text = sta.Single().varDistrict; | |
System.Text.StringBuilder sb = new System.Text.StringBuilder(); | |
sb.Append(@"<script type='text/javascript'>"); | |
sb.Append("$('#AddUpdateModal').modal('show');"); | |
sb.Append(@"</script>"); | |
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AddUpdateModalScript", sb.ToString(), false); | |
btnSave.Visible = false; | |
btnUpdate.Visible = true; | |
lblHeading.Text = "Update Details"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment