viewdata Questions

5

Solved

Hi does anyone know how to pass a list throught the "ViewData". This is what I'm trying but I think I'm missing a cast some where. List<GalleryModel> galleryList = new List<GalleryModel&g...
Gingrich asked 8/11, 2010 at 16:57

7

Solved

[AcceptVerbs(HttpVerbs.Post)] public ActionResult CreateUser([Bind(Exclude = "Id")] User user) { ... db.SubmitChanges(); ViewData["info"] = "The account has been created."; return RedirectToAct...
Nonparous asked 4/8, 2009 at 8:37

9

Solved

In the past I've stuck common properties, such as the current user, onto ViewData/ViewBag in a global fashion by having all Controllers inherit from a common base controller. This allowed my to us...
Gemagemara asked 27/3, 2011 at 23:50

3

Solved

I have been scratching my head about this for a few days, and I am not sure if it is an issue with my environment or the code itself basing this on being to ASP.NET MVC (although I have 5 years exp...
Son asked 20/8, 2012 at 7:13

17

Solved

I saw the ViewBag in MVC 3. How's that different than ViewData in MVC 2?
Dubiety asked 16/1, 2011 at 12:49

6

Solved

I could have used @Html.HiddenFor(x=> ViewData["crn"]) but, I get, <input id="ViewData_crn_" name="ViewData[crn]" type="hidden" value="500" /> To somehow circumvent that issue(id=Vie...
Antifriction asked 27/7, 2011 at 19:32

2

I want to pass an object Model.AvailableVerticalType along with the expression and templateName in the call to the HTML Helper DisplayFor. Without passing the object, the DisplayFor() syntax looks ...
Plerre asked 10/6, 2016 at 7:11

9

Solved

I have a strongly-typed Partial View that takes a ProductImage and when it is rendered I would also like to provide it with some additional ViewData which I create dynamically in the containing pag...
Wismar asked 23/7, 2009 at 1:47

10

Solved

There are a couple of posts about this on Stack Overflow but none with an answer that seem to fix the problem in my current situation. I have a page with a table in it, each row has a number of te...
Tombolo asked 17/5, 2010 at 13:22

2

Solved

How do I add a newline after each item, in a textarea that's inside a Razor @foreach statement? The code below displays everything on one line like... 12341524345634567654354487546765 When I wan...
Piddle asked 3/6, 2016 at 18:17

4

Solved

What is a good way to persist querystring values in asp.net mvc? If I have a url: /questions?page=2&sort=newest&items=50&showcomments=1&search=abcd On paging links I want to keep ...
Ribbon asked 20/5, 2009 at 19:19

2

Solved

I have two ViewComponent and i want use ViewData or other technic for share some data between and then use this data in main view, but this is not the way, and ViewData per ViewComponent is null wh...
Surrounding asked 7/5, 2017 at 6:47

1

Solved

I am sending a filepath ( string) from controller to html page through ViewData and I want to access that string in my javascript, consume it, run some algo in javascript and then use results to co...
Barfly asked 30/12, 2016 at 14:45

3

Solved

I'm struggling myself here, to find a easy way to pass an array from the controller to the view on ASP.NET MVC framework. so in my controller I would have something like: public class HomeControl...
Mckinney asked 10/9, 2009 at 13:42

4

Solved

I use the following in my View to check if a query exists like domain.com/?query=moo if (!string.IsNullOrEmpty(Request.QueryString["query"])) { my code } But now need to change it so that it chec...
Messalina asked 13/1, 2011 at 16:1

4

Solved

I'm experiencing a rather frustrating problem. My MVC site runs fine for the most part, but randomly throws an error (which shows a friendly error to the user). When I check the logs, this is what ...
Callan asked 4/1, 2010 at 3:40

4

I'm trying to pass data from a controller to view, and display these data. But after many tries I can't. Controller code : public ActionResult ValidSearch(ProductSearchParam gp) { if (gp.IsCan...
Cullen asked 15/5, 2015 at 12:45

3

In the view strongly typed view against @model System.Tuple<Person, List<Survey>> I use inside a for-each loop: @Html.EditorFor(x => survey.Questions) to render questions in a `...
Honourable asked 2/9, 2014 at 20:11

3

Solved

I have viewdata in my controller which is populated by a list: List<employee> tempEmpList = new List<employee>(); tempEmpList = context.employees.ToList(); ViewData["tempEmpList"] = te...
Overslaugh asked 23/8, 2012 at 11:52

1

Solved

I have the following table in my View: <table id="tblHelpRow"> <thead> <tr class="title"> <th> 1 </th> <th> 2 </th> <th> 3 </th> &...
Interfuse asked 12/11, 2013 at 22:35

1

Solved

I want to know,What is a best way to create dropdownlists in MVC 4? With ViewBag or another approach?

2

Solved

In my Site.Master file, I have 3 simple ViewData parameters (the only 3 in my entire solution). These ViewData values are critical for every single page in my application. Since these values are us...
Decameter asked 25/11, 2009 at 5:53

6

Solved

I've seen many questions about this, but i've never really got the answer that I need. I'm converting a fairly large web application from Web Forms to MVC and after a while I encountred a problem...
Derte asked 3/1, 2009 at 23:20

4

I have a controller calling a view. In the view there is a partial view, inserted like this: @{ Html.RenderPartial("PartialViewName", this.Model);} This works fine. But in the controller I wis...
Forworn asked 22/6, 2012 at 17:10

2

Solved

I am trying to pass a random string from my Controller to the View. Here is my Controller code: [HttpPost] public ActionResult DisplayForm(UserView user) { //some data processing over here V...
Polity asked 10/1, 2012 at 12:54

© 2022 - 2024 — McMap. All rights reserved.