Click here to Skip to main content
14,665,930 members
Home » Discussions » ASP.NET
   

ASP.NET

 
AnswerRe: EntityFramework: Can we minimize sorting code Pin
Richard Deeming6-Feb-18 3:03
mveRichard Deeming6-Feb-18 3:03 
GeneralRe: EntityFramework: Can we minimize sorting code Pin
Mou_kol7-Feb-18 20:40
MemberMou_kol7-Feb-18 20:40 
GeneralRe: EntityFramework: Can we minimize sorting code Pin
Richard Deeming8-Feb-18 1:39
mveRichard Deeming8-Feb-18 1:39 
GeneralRe: EntityFramework: Can we minimize sorting code Pin
Mou_kol8-Feb-18 1:52
MemberMou_kol8-Feb-18 1:52 
GeneralRe: EntityFramework: Can we minimize sorting code Pin
Richard Deeming8-Feb-18 1:58
mveRichard Deeming8-Feb-18 1:58 
QuestionAny free health monitoring dashboard exist Pin
Mou_kol5-Feb-18 22:00
MemberMou_kol5-Feb-18 22:00 
AnswerRe: Any free health monitoring dashboard exist Pin
Richard MacCutchan5-Feb-18 23:29
mveRichard MacCutchan5-Feb-18 23:29 
QuestionSending a collection of objects to the view in MVC Pin
Davstr5-Feb-18 4:42
MemberDavstr5-Feb-18 4:42 
Hello, I am a Very New programmer in the MVC architecture and I am struggling with getting data from my controller to my view. I am in my last year of college and we are building a web application for a non profit organization that will track residents in their facility.

I am trying to query the database for the rooms table and select the rooms that have the IsOccupied field set to false.

Then I am filtering the returned query for a range of rooms and putting them in Wings and passing them to the view.

My struggles are with getting the room object from the controller to the view. Then in the view, burrowing down into the object and getting the room number out and displaying it.

Currently I have the following in my class.

public class Room
{

public int RoomID { get; set; }

[Display(Name = "Room Number")]
public int RoomNum { get; set; }

[Display(Name = "Is Occupied")]
public bool IsOccupied { get; set; }


}

My Controller code is:

public ActionResult Create()
{


//Query database for IsOccupied flag//
var AvailRoom = from s in db.Rooms
.Where(s => s.IsOccupied == false)
select s;

foreach (var room in AvailRoom)

{
if (room.RoomNum > 101 && room.RoomNum < 126)
{


IEnumerable<selectlistitem> EastSouth = new SelectList(room.RoomNum.ToString());

ViewBag.EastSouth = EastSouth;
}


}

My view code is:

@Html.Label("Available Rooms")




@Html.DropDownList("EastSouth")



Currently all I get when I compile is a dropdown box with 1, 2 and 5.

I am stumped. Any recommendations on where to go from here would be really appreciated.
AnswerRe: Sending a collection of objects to the view in MVC Pin
Richard Deeming5-Feb-18 8:25
mveRichard Deeming5-Feb-18 8:25 
GeneralRe: Sending a collection of objects to the view in MVC Pin
Davstr5-Feb-18 18:24
MemberDavstr5-Feb-18 18:24 
QuestionASP.Net MVC:clicking on routelink url not passing all the data to action Pin
Mou_kol5-Feb-18 3:50
MemberMou_kol5-Feb-18 3:50 
AnswerRe: ASP.Net MVC:clicking on routelink url not passing all the data to action Pin
Richard Deeming5-Feb-18 8:17
mveRichard Deeming5-Feb-18 8:17 
GeneralRe: ASP.Net MVC:clicking on routelink url not passing all the data to action Pin
Mou_kol5-Feb-18 21:56
MemberMou_kol5-Feb-18 21:56 
QuestionHow to calculate page no for newly inserted records Pin
Mou_kol5-Feb-18 2:54
MemberMou_kol5-Feb-18 2:54 
AnswerRe: How to calculate page no for newly inserted records Pin
Maciej Los5-Feb-18 3:23
mveMaciej Los5-Feb-18 3:23 
Questionasp.net mvc routing with two controller reference Pin
Mou_kol5-Feb-18 1:18
MemberMou_kol5-Feb-18 1:18 
AnswerRe: asp.net mvc routing with two controller reference Pin
Richard Deeming5-Feb-18 8:09
mveRichard Deeming5-Feb-18 8:09 
GeneralRe: asp.net mvc routing with two controller reference Pin
Mou_kol5-Feb-18 21:54
MemberMou_kol5-Feb-18 21:54 
GeneralRe: asp.net mvc routing with two controller reference Pin
Richard Deeming6-Feb-18 2:11
mveRichard Deeming6-Feb-18 2:11 
GeneralRe: asp.net mvc routing with two controller reference Pin
Mou_kol6-Feb-18 2:38
MemberMou_kol6-Feb-18 2:38 
GeneralRe: asp.net mvc routing with two controller reference Pin
Richard Deeming6-Feb-18 2:50
mveRichard Deeming6-Feb-18 2:50 
QuestionWhat is Kubernetes and its usage Pin
Mou_kol4-Feb-18 22:11
MemberMou_kol4-Feb-18 22:11 
AnswerRe: What is Kubernetes and its usage Pin
Richard MacCutchan4-Feb-18 23:04
mveRichard MacCutchan4-Feb-18 23:04 
GeneralRe: What is Kubernetes and its usage Pin
Mou_kol5-Feb-18 0:36
MemberMou_kol5-Feb-18 0:36 
GeneralRe: What is Kubernetes and its usage Pin
Richard MacCutchan5-Feb-18 0:42
mveRichard MacCutchan5-Feb-18 0:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.