Chandrakanth M

Chandrakanth M

  • NA
  • 21
  • 11.7k

How to shows selected option in dropdown in a popup window.?

Jul 30 2015 2:02 PM
 Hello friends....when I am click on Edit button in Gridtable,It will displays the Popup window with specific values in textboxes and dropdowns using Jquery in asp.net application ..but Values are not effected in Dropdown..why..?..it will displaying first value like "Select" ..why..please answer me...Code and image shown below
 
My code is:
 
window.operateEvents = {
                'click .edit': function (e, value, row, index) {
                    //alert('You click edit icon, row: ' + JSON.stringify(row));
                    var region = {};
                    region.RegionID = row.RegionID
                    $('#lblvalidmsg').hide();
                    $("#<%=ddlCountry.ClientID%> option[value='" + row.CountryID + "']").attr('selected', 'selected');                              
                    $('#<%=txtRegionName.ClientID%>').val(row.RegionName);                   
                    $('#<%=txtRegionCode.ClientID%>').val(row.RegionCode);
                    $('#<%=txtContactAddress.ClientID%>').val(row.ContactAddress);
                    $("#dialog2").dialog({
                        title: "Region",
                        width: 600,
                        height: 550,
                        modal: false,
                        resizable: false,
                        appendTo: 'form',
                        buttons: {
                            Update: function () {
                                $("[id*=btnupdate]").click()
                                region.RegionID = row.RegionID;
                                region.RegionName = $("[id*=txtRegionName]").val();
                                region.RegionCode = $("[id*=txtRegionCode]").val();
                                region.ContactAddress = $("[id*=txtContactAddress]").val();
                                    region.CountryID = $("[id*=ddlCountry]").val();
                            debugger;
                            if(region.RegionName==='' || region.RegionCode==='' || region.ContactAddress==='' || region.CountryID<=0)
                            {
                                $('#lblvalidmsg').show();
                                $('#lblvalidmsg').html("Please Enter all Mandatory fields");
                            }
                            else
                             {
                                $.ajax({
                                    type: "POST",
                                    url: "Region.aspx/updateRegion",
                                    data: '{region: ' + JSON.stringify(region) + '}',
                                    contentType: "application/json; charset=utf-8",
                                    dataType: "json",
                                    success: function (response) {
                                      
                                       alert("Region has been Update successfully.");
                                        window.location.reload();
                                    }
                                });
 
}
Displaying 2.PNG

Answers (5)