Questions tagged [viewbag]

ViewBag is a dynamic type object in the ASP.NET MVC framework that can be used to send miscellaneous data from the controller to the view.

ViewBag is a member of the ControllerBase class in the ASP.NET MVC framework. It's a dynamic type object that can be used to send miscellaneous data from the controller to the view. Its type is dynamic.

718 questions
-1
votes
2 answers

TempData doesn't carry the data in second action

I have a Partial View and fill my TempData with this code block. serviceResponsecont is a list. TempData["partialResponseList"] = serviceResponseCont; After this from the PartialView I call the same controller and try to get same data like…
-1
votes
1 answer

How can I pass the value of a list into a partial view using ViewBag?

I have a Index view showing all posts in my database. And I want to create a partial view that displays 5 most viewed posts. Here is my PostController : public class PostController : Controller { private readonly IUnitOfWork uow; …
-1
votes
3 answers

Viewbag not properly working transfer the wrong data

I am student. I am new to ASP.NET MVC and I google it and I tried see I write all code but viewbag not properly working I am transferring data and using the viewing but not transferring the dropdown value type.cs public class Type { //public int…
Developer
  • 15
  • 6
-1
votes
1 answer

ASP.NET MVC ViewBag values not being displayed in view after Ajax call

I have following view and controller code: Index.cshtml @using (Html.BeginForm("Create", "Home", FormMethod.Post, new { enctype = "multipart/form-data" })) { @ViewBag.Message
Mohan Raju
  • 59
  • 8
-1
votes
1 answer

Operator '!=' cannot be applied to operands of type SelectListItem

I'm new to ASP.NET MVC and need your help with a specific question. I'm working on a School Application. The app is capable to registers students in db and principal (Admin) can assign them to groups. Here is code from controller public async…
-1
votes
2 answers

ViewBag ASP NET CORE MVC | CallSite.Target(Closure , CallSite , object )

I'm actually stuck & I don't understand this issue. I mean, I really don't get it why it doesn't work. Here's the error : & here's the code, Index.cshtml : @{ ViewBag.Title = ViewBag.client.Name; } [...] HomeController.cs : private readonly…
Hashka
  • 395
  • 3
  • 10
-1
votes
1 answer

Viewbag New Selectlist Placeholder

I have a simple select list being generated in my action method (code below) Viewbag.Select = new SelectList(db.esp_admin_form_demographics.Where(x => x.category == (int) SelectHelper.ClientSelectOptions.Demographics.BirthCountry || x.category ==…
Paul Coan
  • 302
  • 1
  • 3
  • 15
-1
votes
1 answer

Select List from Dictionary giving error

I create a viewbag as below Dictionary actlist = new Dictionary(); foreach() { //filling the dictionary } ViewBag.act_type = new SelectList(actlist, "Value", "Key"); In the view call the view bag as…
Sachu
  • 7,555
  • 7
  • 55
  • 94
-1
votes
1 answer

Loading MVC Dropdowns using viewbags ajax when changing a dropdown?

@Html.DropDownList("CountryID", (SelectList)ViewBag.CounrtyList,new { style = "width:150px;" }) @Html.DropDownList("CityID", (SelectList)ViewBag.CityList,new { style = "width:150px;" }) @Html.DropDownList("StateID",…
-1
votes
2 answers

MVC Viewbag correct Result count but displaying only item 1

Trying to use a viewbag on a create form (view) to let the user pick an "item" on the dropdown. The dropdown displays and shows correct number of rows (tested) but only displays the first item for the X number of…
-1
votes
1 answer

How to get multi table and paste to multi dropdowListFor on view

I'm newbie ASP.NET MVC. I have many table such as (Country, State and city). I want to put value in these DropDownListFor in one view. Could you help me please. Sorry for my bad question and bad English skill.
-1
votes
1 answer

Display table based on individual column search: Retain search field and value

I am using Razorview and Entity Framework and I am trying to achieve the following: I have a dropdown(id=ColumnName) that has a list of column names and a textbox(id=SearchValue) for value to be searched from a table. On click of a button, I am…
user7221204
  • 99
  • 3
  • 12
-1
votes
1 answer

Set TextBox value from ViewBag list in MVC5 C#

How can I set TextBox value in MVC5 from ViewBag which contains a list? As you can see my list is in Viewbag.photos and I want to have each value of photo.id in my TextBox and then pass it to controller @foreach (var photo in ViewBag.photos) …
curious
  • 85
  • 1
  • 9
-1
votes
1 answer

How to assign data to EditorFor using TempData or ViewBag

I want to assign EST_ID from index.cshtml to Create.cshtml view which uses Html.Editorfor(model=>model.EST_ID). how to assign EST_ID to Html.Editorfor(model=>model.EST_ID) using TempData or ViewBag by getting EST_ID from table in…
-1
votes
1 answer

c# ActionController returns ActionController Viewbag = empty

Just like the 1st question that i asked here. I am working with a group on a project for our scool. We learned alot at this moment but we have just 1 issue I Made a Logincontroller and in each Controller there is a call to the logincontroller to…