Click here to Skip to main content
14,243,792 members
Rate this:
Please Sign up or sign in to vote.
See more:
HI,
I am trying to set values to multi select drop down .
The values are getting selected but the selected value text is not displayed on the text box.

What I have tried:

ASPX page



Ajax to set the value for Multi select drop down
$.ajax({
url: 'NewTicket.aspx/getEditDate',
data: "{'TicketId':'" + obj + "'}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (data) {
var TicketId = data.d.TicketId;
$('#ContentPlaceHolder1_hdnTicketId').val(TicketId);
$('#ContentPlaceHolder1_txtCustomer').val(data.d.CustomerName);
debugger;
//$('#ContentPlaceHolder1_txtName').val();
//$('#ContentPlaceHolder1_file2').val(data.d.Comments);
var IssueSummary = data.d.IssueSummary;

// $('#ddlissurtopic').select2("val", IssueSummary)({
// });
///To get Issue Summary for multi select
$('#ddlissurtopic').val(IssueSummary);
var selectedOptions = IssueSummary.split(',');
for (var i in selectedOptions) {
var optionVal = selectedOptions[i];
$("ddlissurtopic").find("option[value=" + optionVal + "]").prop("selected", "selected");
}
// $("ddlissurtopic").multiselect('reload');


// var opts = IssueSummary.split(",");
// $.each(IssueSummary.split(","), function (i, e) {
// $("#ddlissurtopic option[value='" + e + "']").prop("selected", true);
// });

$('.select2-selection--multiple').attr('aria-expanded','true');
//$('#ddlissurtopic').trigger("change");
// $.each(opts, function (inx, val) {
// $('#ddlissurtopic option[value=' + val + ']').attr('selected', true);
// })
// $('#ddlissurtopic').val(IssueSummary);

//$("#ddlissurtopic").val(data.SpecialInstructions);
// $('#ddlissurtopic').multiselect("refresh");
//$('#ddlissurtopic').multiSelect("select", IssueSummary);

//$('#ddlissurtopic').setAttribute("aria-hidden", "false");

// $('#ddlissurtopic').val(data.d.IssueSummary);
},
error: function (err) {
alert(err);
console.log(err);
}
});
Posted
Updated 28-Apr-19 19:46pm
v3
Comments
Christian Graus 29-Apr-19 1:47am
   
What library is providing this control?
harish kashyap01 29-Apr-19 4:01am
   
init-select2.js
select2.min.js
select2.min.css
Christian Graus 29-Apr-19 4:22am
   
Can you give us a name or a URL? Your issue is with a library. My work day is slow enough that I'd look at it if you told me which one
harish kashyap01 29-Apr-19 5:05am
   
http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/js/bootstrap-multiselect.js
harish kashyap01 29-Apr-19 5:08am
   
Hi,
the values are getting selected in multi select drop down list but not showing the selected value text in edit mode

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100