dcsimg
Results 1 to 3 of 3

Thread: How to use model for multiple lists of data

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2015
    Posts
    75

    How to use model for multiple lists of data

    What's the best way to pass multiple lists of data to a view? I saw someone answer the question on another site and they said to use the model for one list and ViewData for the other. That seems pretty weak to me. From what I understand the model is the preferred method for passing data to a view. I'm assuming the model would be able to handle more than one list.

  2. #2
    Frenzied Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,078

    Re: How to use model for multiple lists of data

    If you create a custom model for the view (often referred to as a ViewModel) you could give the model two properties, each property would contain the data for the associated list.

    Personally I would always try to avoid using ViewData (or ViewBag) as you lose all type safety and compile time support, a strongly typed model is always the way to go in my mind.

  3. #3
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,550

    Re: How to use model for multiple lists of data

    Personally I would always try to avoid using ViewData (or ViewBag) as you lose all type safety and compile time support, a strongly typed model is always the way to go in my mind.
    Agreed, i have models with multiple lists in which i bind to dropdowns or grids, its fairly standard.
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width