Custom View data from partial view to view

Posted by Hers under ASP.NET MVC on 3/28/2017 | Points: 10 | Views : 394 | Status : [Member] | Replies : 1

I am new to ASP.NET MVC. I would like to get some help on getting custom data from controller to view.

I have queried and concatenated the result of a table from model based on a criteria. I want this to be viewed as a partial view in the Index page. For this, I pass the queried result as follows
return PartialView(rds.ToList())

The purpose is to display a listview of these items in the Index view as partial. I don't know how to grab this data from the partial view. Please help.



Posted by: Shreedar on: 9/25/2017 [Member] Starter | Points: 25

You can store the list in session as below and call your partial view.
Session["Data"]= rds.ToList();
return View("PartialViewName");

In the partial view you can type cast the session data to your required list type.
Information lst=Session["Data"] as Information; so on


Sridhar Thota.

Hers, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response