Hi All,
I am new to the MVC 3. I want to do like below.
I have created two Model Class Item1 and Item2.
class Item1
{
public int Item1ID {get; set; }
publid string ItemName {get; set; }
}
And
class Item2
{
public int Item2ID { get; set; }
public string ItemName {get; set; }
}
And One dataContext class
public class ItemDBContext:DbContext
{
public DbSet<Item1> Items1 { get; set; }
public DbSet<Item2> Items2 { get; set; }
}
No in controller Index() methos i am populating the dropdown list using below code
public ItemDBContext db=new ItemDBContext();
public ActionResult Index()
{
ViewBag.item1List=new SelectList (db.Item1s, "Item1ID","ItemName","Please select any one");
ViewBag.item2List=new SelectList (db.Item2s, "Item2ID","ItemName","Please select any one");
return View();
}
Now in view I am using these two ViewBag to populate two dropdon list.
@using (Html.BeginForm())
{
@Html.DropdownList("item1List",string.Empty); <br />
<input type="submit" name="onetotwo" text=">>" /> <br />
<input type="submit" name="twotoone" text="<<" /> <br />
@Html.DropdownList("item1List",string.Empty); <br />
}
Both the dropdownlist are populated properly.
Now i want to do like below. I don't to how to do this.
After selecting any value from First dropdown list and click on ">>" button then that selected item should removed from first dropdownlist and it should be added to second dropdownlist. Same this should be done in database too.
Please can anyonce tell me how can i write the
[HttpPost] version of the Index() method.
Please help me to resolve this isse. Really i need this thing.
Thanks and Regards in Advance.
Suman Zalodiya.