rifat mojumder

rifat mojumder

  • 1.6k
  • 190
  • 2.4k

List Box Value Save

Feb 28 2017 2:06 AM
my first 1st list box data move 2nd  listbox but how can save 2nd list box data in my data base.Below My Code..
 
 
<div class="col-sm-12 col-lg-12">
<div class="col-md-4">
@Html.ListBoxFor(x => x.CommonCodeID, Model.CommoncodeItemsnull, new { @class = "BranchName", @style = "width:200px;height:100px;" })
</div>
<div class="col-sm-8 col-lg-8">
<input type="button" id="left" value="<" />
<input type="button" id="right" value=">" />
<input type="button" id="leftall" value="<<" />
<input type="button" id="rightall" value=">>" />
</div>
<div class="col-md-10">
@Html.ListBoxFor(x =>x.CommonCodeID, Model.CommoncodeItems, new { @class = "secounlist", @style = "width:200px;height:100px;" })
</div>
</div>
 
 <script>
(function () {
$('#right').click(function (e) {
var selectedOpts = $('.BranchName option:selected');
if (selectedOpts.length == 0) {
alert("Nothing to move.");
e.preventDefault();
}
$('.secounlist').append($(selectedOpts).clone());
$(selectedOpts).remove();
e.preventDefault();
});
$('#left').click(function (e) {
var selectedOpts = $('.secounlist option:selected');
if (selectedOpts.length == 0) {
alert("Nothing to move.");
e.preventDefault();
}
$('.BranchName').append($(selectedOpts).clone());
$(selectedOpts).remove();
e.preventDefault();
});
}(jQuery));
 
</script> 
 
 ----------------------
model :
public int[] CommonCodeID { get; set; } 
 
 
 

Answers (3)