asp.net mvc - MultiSelectList problem, getting right type -
I'm having trouble with the selected getting items in a multiple selection
I have done this:
BookingObject bo = _bs.GetBookingObjects (bookingobjectID.Value). FirstOrDefault (); Bo.BookingViews.Load (); MultiSelectList BookingViewsBookingObjects = new MultiSelectList (_bvs.GetBookingViews (), "BookingViewID", "BookingViewName", (IEnumerable & LT; BookingView & gt;) bo.BookingViews.ToList ());
BookingViews & lt; -> BookingViewsBookingObjects & lt; -> BookingObjects
Many of this make many connections. _bvs.GetBookingViews () IQueryable returns BookingView, and I can not seem to get the item selected bo.BookingViews.
What can be missing here? Am I using the wrong type?
/ M
Perhaps you will send real-selected value in the last parameter IEnumerable & lt; BookingView & gt;
instead of "BookingViewID", it is a IEnumerable & lt; Int & gt;
if BookingViewID something like integer,:
MultiSelectList BookingViewsBookingObjects = new MultiSelectList (_bvs.GetBookingViews (), "BookingViewID", "BookingViewName", (IEnumerable & LT; integer & Gt;) Bow.BuckingView Select (a => a.BookingViewID) .Oolist ());
Edit: Full Code
Setup Data (Controller / ViewModel) :.
from the list & lt; KeyValuePair & LT; Integer, string & gt; & Gt; List = new list & lt; KeyvaluePair & lt; Int, string & gt; & Gt; () ;; List Add (new keypair & lt; int, string & gt; (1, "value1")); List Add (new keypair & lt; int, string & gt; (2, "value2"); List Add (new keychair & lt; int, string & gt; (3, "value 3")); List Add (new keypad & lt; int, string & gt; (4, "value 4")); & Lt; Integer & gt; Selected = new list & lt; Int & gt; {1,2}; SeeData ["Multi"] = New Multi Sealist (List F. Incommentable (), "Key", "Value", selected);
(View):
& lt;% = HTML.ListBox (See "Multi Silackt", "as multi Sillist" [%] "%".
Comments
Post a Comment