I have an HTML table which loads data from the database. When I click on a row a modal pop fetches more content from the database with an option to edit a change on the selected row.
My predicament is how do I populate a drop-down list and select a value saved in the database?
It is easy to bind other controls i.e. Textarea, input boxes etc. My issue is with dropdown lists.
FYI I'm using ASP.NET Web Forms with C# and I fetch the data from the database using jQuery AJAX and a WebService. Thanx in advance.
I have updated the question here is the js:
C#
$("body").delegate("a.view-link", "click", function (e) {C#
e.preventDefault();C#
var requestID = $(this).data("reqid");C#
$.ajax({C#
type: "POST",C#
url: "../helpdeskservice.asmx/GetModalContent",C#
data: "{'requestID':'" + requestID + "'}",C#
contentType: "application/json;C#
charset=utf-8",C#
dataType: "json",C#
success: function (response) {C#
$('#modalEditCall').html(response.d);C#
$('#requestConfirmed').modal('toggle') }C#
});C#
$('#modalEditCall').modal('toggle')C#
});C#
[WebMethod]C#
public string GetModalContent(string requestID)C#
{C#
tryC#
{C#
return ViewExtensions.GetCallModal(requestID);C#
}C#
catch (Exception ex)C#
{C#
throw ex;C#
}C#
}C#
Here is a screen shot of the modal popup.C#

Manav PandyaRank #166 · 14.3K reputationPosted Feb 15, 2018, 2:48 AM EST