Mukesh

Mukesh

  • NA
  • 228
  • 43.2k

How to bind dropdown using jquery

Nov 24 2018 6:18 AM
@Html.DropDownListFor(x => x.Source, new SelectList(Model.SourceList, "Code", "Text"), "Select", new { @id = "ddlSourceId", @class = "form-control" })
function AddDynamicControl() {
debugger;
$("#DynamicControl").append('<div class="col-sm-3"><div class="form-group"><label class="col-sm-3 control-label">Source</label><div class="col-sm-5"><input type="text" name="Source"/></div></div></div><div class="col-sm-3"><div class="form-group"><label class="col-sm-3 control-label">Destination </label><div class="col-sm-9" style="padding-left:35px"><select></select> <div class="col-sm-2"><div class="form-group"><label class="col-sm-3 control-label">STD</label><div class="col-sm-9"><input type="text" id="txtSTD" name="std"/><span class="glyphicon glyphicon-calendar"></span></div></div></div></div></div></div><div class="col-sm-2"><div class="form-group"><label class="col-sm-3 control-label">DateTime</label><div class="col-sm-9" style="padding-left:35px"><input type="text" id="txtDateTime" name="DateTime"/><span class="glyphicon glyphicon-calendar"></span></div></div></div><input type="button" onclick="Remove(this)" value="Remove"/>');
};
</script>
$d(function () {
$d('#txtSTD').datetimepicker();
});
var $d = jQuery.noConflict();
$d(function () {
$d('#txtDateTime').datetimepicker();
});
 
above i write code where i bind dropdown and i take i div and button when click on button then 4 control open using jquery so i want to know how to bind dynamic dropdownlist when i append in jquery
 
i want to bind same dropdown where i take in strongly type dropdownlist in mvc
and when i click on addbutton the calender will also open in std and datetime

Answers (2)