how to data copy in listbox1 and store viewbag but viewbag data display and store in listbox 2
My controller code ------------------
public ActionResult Index()
{
DataClasses1DataContext db = new DataClasses1DataContext();
List objlist = (from data in db.TestTables
select data).ToList();
SelectList objmodeldata = new SelectList(objlist, "ColumnID", "ColumnID");
/*Assign value to model*/
CountryModel objListmodel = new CountryModel();
objListmodel.ListModel = objmodeldata;
return View(objListmodel);
}
[HttpPost]
public ActionResult Index(string listcountry)
{
DataClasses1DataContext objentity = new DataClasses1DataContext();
List objlist = (from data in objentity.TestTables
select data).ToList();
TestTable objdata = new TestTable();
objdata.ColumnID = "SELECT";
// objdata.ColumnID = 0;
objlist.Insert(0, objdata);
SelectList objmodeldata = new SelectList(objlist, "ColumnID", "ColumnID");
CountryModel objcountrymodel = new CountryModel();
objcountrymodel.ListModel = objmodeldata;
ViewBag.ColumnID = objlist.Where(m => m.ColumnID ==
listcountry).FirstOrDefault().ColumnID;
return View(objcountrymodel);
}
View Code---------------------------------------------
@model MvcLIstBoxTask.Models.CountryModel
@{
ViewBag.Title = "Bind ListBox in MVC Using C#.Net";
}
@using (Html.BeginForm("Index", "Home"))
{
Bind ListBox
@Html.ListBox("listcountry", Model.ListModel, new { @style = "width:200px;height:100px;" })
Selected list :@ViewBag.ColumnID
}
please help me any one ......

Manas MohapatraRank #182 · 13.2K reputationPosted Dec 28, 2015, 2:37 AM EST
Deepak AwashtiRank #6,113 · 276 reputationPosted Dec 28, 2015, 2:46 AM EST
Deepak AwashtiRank #6,113 · 276 reputationPosted Dec 28, 2015, 8:46 PM EST
Ranjit PowarRank #553 · 4.4K reputationPosted Dec 28, 2015, 8:56 PM EST
Deepak AwashtiRank #6,113 · 276 reputationPosted Dec 28, 2015, 9:04 PM EST
Ranjit PowarRank #553 · 4.4K reputationPosted Dec 28, 2015, 9:08 PM EST
Deepak AwashtiRank #6,113 · 276 reputationPosted Dec 28, 2015, 9:18 PM EST
Bind ListBox
Ranjit PowarRank #553 · 4.4K reputationPosted Dec 28, 2015, 9:24 PM EST
<script type="text/javascript">
$(function () {
$("#Button1").click(function (event) {
var ChooseFrom = $("#ListBox1");
var moveTo = $("#ListBox2");
var SelectData = $(ChooseFrom + " :selected").toArray();
$(moveTo).append(SelectData);
SelectData.remove;
});
});
script>
Deepak AwashtiRank #6,113 · 276 reputationPosted Dec 28, 2015, 9:40 PM EST
Ranjit PowarRank #553 · 4.4K reputationPosted Dec 28, 2015, 10:03 PM EST