Ramco Ramco

Ramco Ramco

  • 464
  • 2.8k
  • 402.8k

Value in alert is correct but in dropdown it is not showing

Aug 15 2022 2:16 AM

Hi

  Value in State dropdown is not showing

private void GetData()
{
    try
    {
        StringBuilder htmlTable = new StringBuilder();

        BALAcademy bALAcademy = new BALAcademy();
        List<AcademyMaster> Result = bALAcademy.GetRecordList();

        if (Result != null)
        {
            htmlTable.Append("<table class='table table-bordered table-hover datatable-highlight' id='tbldata'>");

            //htmlTable.Append("<thead><tr><th>State</th><th>Country</th><th>Status</th><th class='text-center nosort'>Actions</th><th style='display:none'>#</th><th style='display:none'>1</th></tr></thead>");
            htmlTable.Append("<thead><tr><th>Academy Id</th><th>Academy Name</th><th>Academy Address</th><th>Academy State</th><th>Academy Phone No</th><th>Academy Email</th><th class='text-center nosort'>Actions</th><th style='display:none'>1</th></tr></thead>");
            htmlTable.Append("<tbody>");

            foreach (var colum in Result)
            {
                String Status = colum.Active == true ? "Active" : "Blocked";

                htmlTable.Append("<tr>");

                htmlTable.Append("<td>" + colum.AcademyID + "</td>");
                htmlTable.Append("<td>" + colum.AcademyName + "</td>");
                htmlTable.Append("<td>" + colum.AcademyAddress + "</td>");
                htmlTable.Append("<td>" + colum.StateMaster.StateName + "</td>");
                htmlTable.Append("<td>" + colum.AcademyPhoneNumber + "</td>");
                htmlTable.Append("<td>" + colum.AcademyEmail + "</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.AcademyID + "</td>");
                htmlTable.Append("<td style='display:none'>" + colum.Active + "</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");
    }
}
<script type="text/javascript">
    function BindData(e) {
        document.getElementById('btnSave').value = "Update";

        var currentRow = $(e).closest("tr");
        var AcademyId = currentRow.find("td:eq(0)").text();
        var Name = currentRow.find("td:eq(1)").text();
        var Address = currentRow.find("td:eq(2)").text();
        var State = currentRow.find("td:eq(3)").text();
        var PhoneNo = currentRow.find("td:eq(4)").text();
        var Email = currentRow.find("td:eq(5)").text();
        var Active = currentRow.find("td:eq(7)").text();
        /*alert(State);*/
        document.getElementById('hdfID').value = AcademyId;
        document.getElementById('txtAcademyName').value = Name;
        document.getElementById('txtAddress').value = Address;
        $("#<%=ddlState.ClientID%>").val(State);
        document.getElementById('txtPhoneNo').value = PhoneNo;
        document.getElementById('txtEmail').value = Email;
        $("#<%=ddlStatus.ClientID%>").val(Active);
    };

    function Save() {
        document.getElementById('btnSave').value = "Save";
        document.getElementById('hdfID').value = "0";
        document.getElementById('txtAcademyName').value = "";
        document.getElementById('txtAddress').value = "";
        $("#<%=ddlState.ClientID%>").val("");
        document.getElementById('txtPhoneNo').value = "";
        document.getElementById('txtEmail').value = "";
        $("#<%=ddlStatus.ClientID%>").val("True");
    };
</script>

Thanks


Answers (1)