-
Sep 2nd, 2019, 04:14 PM
#1
Thread Starter
Lively Member
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.
-
Sep 2nd, 2019, 04:20 PM
#2
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.
-
Sep 3rd, 2019, 02:56 AM
#3
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
-
Dec 30th, 2019, 04:31 AM
#4
Banned
Re: How to use model for multiple lists of data
Originally Posted by PlausiblyDamp
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.
Totally agree with you here!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|