Search Results

Search found 2 results on 1 pages for 'sheefy'.

Page 1/1 | 1 

  • Asp.Net (C#) MVC Routing - Trying avoid using the same controller in different places and think rout

    - by sheefy
    Hi Guys, I'm currently building a site which has a bunch of main categories and in each category you can perform a search. Basically, I want my addresses to work like this... When the website loads (as in when someone goes to www.mySite.com) it will redirect them to the default category. www.mySite.com/Category Then when you search within a category, the results would come up in a page like the following. www.mySite.com/Category/Search I want to put everything in one controller and have one main view for the Category and one for the Search, I would then render these based on which category is currently being viewed. Can this be done, maybe with routing? I don't want to have to create a different controller for each category as it's just duplicating a lot of the code. Thanks in advance for your help.

    Read the article

  • Saving Data to Relational Database (Entity Framework)

    - by sheefy
    I'm having a little bit of trouble saving data to a database. Basically, I have a main table that has associations to other tables (Example Below). Tbl_Listing ID UserID - Associated to ID in User Table CategoryID - Associated to ID in Category Table LevelID - Associated to ID in Level Table. Name Address Normally, it's easy for me to add data to the DB (using Entity Framework). However, I'm not sure how to add data to the fields with associations. The numerous ID fields just need to hold an int value that corresponds with the ID in the associated table. For example; when I try to access the column in the following manner I get a "Object reference not set to an instance of an object." error. Listing NewListing = new Listing(); NewListing.Tbl_User.ID = 1; NewListing.Tbl_Category.ID = 2; ... DBEntities.AddToListingSet(NewListing); DBEntities.SaveChanges(); I am using NewListing.Tbl_User.ID instead of NewListing.UserID because the UserID field is not available through intellisense. If I try and create an object for each related field I get a "The relationship between the two objects cannot be defined because they are attached to different ObjectContext objects." error. With this method, I am trying to add the object without the .ID shown above - example NewListing.User = UserObject. I know this should be simple as I just want to reference the ID from the associated table in the main Listing's table. Any help would be greatly appreciated. Thanks in advance, -S

    Read the article

1