Hi
I have below Aspx. When i select KRA value it should fresh SubKRA dropdown but it closes the Modal.
<div class="form-horizontal"> <div class="modal-body"> <div class="row"> <div class="col-lg-6 col-md-6 col-sm-12"> <div class="form-group"> <label>KRA</label> <span style="color: red">*</span> <asp:DropDownList ID="ddlKRA" class="form-control" runat="server" required="true" AutoPostBack="true" OnSelectedIndexChanged="KRA_Changed"> <asp:ListItem Value="">Select KRA</asp:ListItem> </asp:DropDownList> </div> </div> <div class="col-lg-6 col-md-6 col-sm-12"> <div class="form-group"> <label>Sub KRA</label> <span style="color: red">*</span> <asp:DropDownList ID="ddlSubKRA" class="form-control" runat="server" required="true"> <asp:ListItem Value="">Select Sub KRA</asp:ListItem> </asp:DropDownList> </div> </div> </div> </div> </div>
protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { BindKRAMaster(); GetData(); } } catch (Exception ex) { Utility.SaveErrorLog(ex.Message, System.IO.Path.GetFileName(Request.Path), System.Reflection.MethodBase.GetCurrentMethod().Name, hdfEmpNumber.Value); ShowMessage("Oops...", ex.Message, "error"); } } private void GetData() { try { StringBuilder htmlTable = new StringBuilder(); BALAchievementMeasurement bALAchievementMeasurement = new BALAchievementMeasurement(); List<AchievementMeasurementSetup> Result = bALAchievementMeasurement.GetRecordList(); if (Result != null) { htmlTable.Append("<table class='table table-bordered table-hover datatable-highlight' id='tbldata'>"); htmlTable.Append("<thead><tr><th style='display:none'>Id</th><th>KRASetup Id</th><th>Sub KRASetup Id</th><th>Performance Goal</th><th>Payout</th><th>Action Plan</th><th>Status</th><th class='text-center nosort'>Actions</th><th style='display:none'>#</th><th style='display:none'>1</th><th style='display:none'>2</th><th style='display:none'>3</th><th style='display:none'>4</th></tr></thead>"); htmlTable.Append("<tbody>"); foreach (var colum in Result) { String Status = colum.Active == true ? "Active" : "Blocked"; String modifyAllowed = colum.ModificationAllowed == true ? "Yes" : "No"; String deleteAllowed = colum.DeleteAllowed == true ? "Yes" : "No"; htmlTable.Append("<tr>"); htmlTable.Append("<td style='display:none'>" + colum.AchievementSetupID + "</td>"); htmlTable.Append("<td>" + colum.KRASetupID + "</td>"); htmlTable.Append("<td>" + colum.SubKRASetupID + "</td>"); htmlTable.Append("<td>" + colum.Performance + "</td>"); htmlTable.Append("<td>" + colum.Payout + "</td>"); htmlTable.Append("<td>" + colum.ActionPlan + "</td>"); //htmlTable.Append("<td>" + colum.DeleteAllowed + "</td>"); //htmlTable.Append("<td>" + colum.ModificationAllowed + "</td>"); htmlTable.Append("<td>" + Status + "</td>"); htmlTable.Append("<td class='text-center'><a id='btnEdit' style='cursor:pointer;' class='list-icons-item text-primary-600' data-toggle='modal' data-backdrop='static' data-keyboard='false' data-target='#modal_form_horizontal' onclick='BindData(this);'><i class='icon-pencil7 mr-1'></i></a></td>"); htmlTable.Append("<td style='display:none'>" + colum.Active + "</td>"); htmlTable.Append("<td style='display:none'>" + colum.KRASetupID + "</td>"); htmlTable.Append("<td style='display:none'>" + colum.SubKRASetupID + "</td>"); htmlTable.Append("<td style='display:none'>" + colum.DeleteAllowed + "</td>"); htmlTable.Append("<td style='display:none'>" + colum.ModificationAllowed + "</td>"); htmlTable.Append("</tr>"); } htmlTable.Append("</tbody>"); htmlTable.Append("</table>"); PlaceHolderTable.Controls.Add(new Literal { Text = htmlTable.ToString() }); } } catch (Exception ex) { Utility.SaveErrorLog(ex.Message, System.IO.Path.GetFileName(Request.Path), System.Reflection.MethodBase.GetCurrentMethod().Name, hdfEmpNumber.Value); ShowMessage("Oops...", ex.Message, "error"); } } private void BindKRAMaster() { try { BALKRASetup bALKRASetup = new BALKRASetup(); List<KRASetupMaster> Result = bALKRASetup.GetActiveRecordList(); if (Result != null) { ddlKRA.DataTextField = "KRASetupID"; ddlKRA.DataValueField = "KRASetupID"; ddlKRA.DataSource = Result; ddlKRA.DataBind(); ddlKRA.Items.Insert(0, new ListItem("Select KRASetupID", "")); } } catch (Exception ex) { Utility.SaveErrorLog(ex.Message, System.IO.Path.GetFileName(Request.Path), System.Reflection.MethodBase.GetCurrentMethod().Name, hdfEmpNumber.Value); ShowMessage("Oops...", ex.Message, "error"); } } protected void KRA_Changed(object sender, EventArgs e) { try { ddlSubKRA.Items.Clear(); if (ddlKRA.SelectedItem.Value != "") { Int32 SubKRA = int.Parse(ddlKRA.SelectedItem.Value); if (SubKRA > 0) { BindSubKRA(); } } } catch (Exception ex) { Utility.SaveErrorLog(ex.Message, System.IO.Path.GetFileName(Request.Path), System.Reflection.MethodBase.GetCurrentMethod().Name, hdfEmpNumber.Value); ShowMessage("Oops...", ex.Message, "error"); } } private void BindSubKRA() { try { BALSubKRASetup bALSubKRASetup = new BALSubKRASetup(); List<SubKRASetupMaster> Result = bALSubKRASetup.GetRecordListByKRA(Convert.ToInt32(ddlKRA.SelectedItem.Value)); if (Result != null) { ddlSubKRA.DataTextField = "SubKRASetupID"; ddlSubKRA.DataValueField = "SubKRASetupID"; ddlSubKRA.DataSource = Result; ddlSubKRA.DataBind(); ddlSubKRA.Items.Insert(0, new ListItem("Select Sub KRA", "")); } } catch (Exception ex) { Utility.SaveErrorLog(ex.Message, System.IO.Path.GetFileName(Request.Path), System.Reflection.MethodBase.GetCurrentMethod().Name, hdfEmpNumber.Value); ShowMessage("Oops...", ex.Message, "error"); } }
Thanks