How do I Keep Razor Page Sort in mvc?

Hi guys,
I'm doing a basic Movie MVC application. I have a sorting that will display movies in the order of there 
MovieId on the Home page, in the view, there is a link you can press to rearrange the movies alphabetically based on the Movie Name. However when I go to another Page and later return, the Sorting will always go back to being organised by MovieId, is there
anyway to be able to keep the sorting as alphabetical if I leave and return to the Home Page?
public class HomeController : Controller
private MovieDb db = new MovieDb();
public ActionResult Index(string sort, string Search_Data)
{ //Variable sort for sorting
IQueryable<Movie> movie = db.Movies;
ViewBag.SortingName = String.IsNullOrEmpty(sort) ? "Name_Description" : "";
//Search bar
if (!String.IsNullOrEmpty(Search_Data))
movie = movie.Where(s => s.MoviesName.Contains(Search_Data));
//Search bar
var albu = from alb in db.Movies select alb;
albu = albu.Where(alb => alb.MoviesName.ToUpper().Contains(Search_Data.ToUpper()));
//Sorting in switch
switch (sort)
case "Name_Description":
movie = movie.OrderBy(alb => alb.MoviesName);
break;
default:
movie = movie.OrderBy(alb => alb.MovieID);
break;
return View(movie.ToList());
public ActionResult Details(int id = 0)
Movie m = db.Movies.Find(id);
if (m == null)
return HttpNotFound();
else
//HEY SHOW ME ACTORS
m.Actors = (from e in db.Actors
where e.MovieID.Equals(id)
select e).ToList();
//m.Actors.Count();
return View(m);
#region Create Movie
public ActionResult Create()
return View();
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(Movie movie)
if (ModelState.IsValid)
db.Movies.Add(movie);
db.SaveChanges();
return RedirectToAction("Index");
return View(movie);
#endregion
#region Edit Movie
public ActionResult Edit(int id)
Movie movie = db.Movies.Find(id);
if (movie == null)
return HttpNotFound();
return View(movie);
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(Movie movie)
if (ModelState.IsValid)
db.Entry(movie).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
return View(movie);
#endregion
#region Delete Movie
public ActionResult Delete(int id)
Movie movie = db.Movies.Find(id);
return View(movie);
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
Movie movie = db.Movies.Find(id);
db.Movies.Remove(movie);
db.SaveChanges();
return RedirectToAction("Index");
#endregion
Here is the view
<h2>Movies</h2>
<p>
@Html.ActionLink("All Actors", "Index", "Actor", null, new { @class = "btn btn-success" })
</p>
<p>
@Html.ActionLink("Create New", "Create", null, new { @class = "btn btn-primary" })
</p>
@using (Html.BeginForm("Index", "Home", FormMethod.Get))
<p>
Search Name: @Html.TextBox("Search_Data")
<input type="submit" value="Filter" />
</p>
@Html.ActionLink("Rearrange Alphabetically", "Index", new { sort = ViewBag.SortingName})
<div class="table-responsive" >
<table class="table table-striped">
<tr class="info">
<th>
@Html.DisplayNameFor(model => model.MoviesName)
</th>
<th>
@Html.DisplayNameFor(model => model.Description)
</th>
<th></th>
</tr>
@foreach (var item in Model)
<tr>
<td>
<a href="@Url.Action("Details", null, new{id = item.MovieID})">@Html.DisplayFor(modelItem => item.MoviesName)</a>
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
<div class="form-group">
<div class="btn-group" data-toggle="buttons">
<label class="pdsa-radiobutton btn btn-warning active">
<span class="glyphicon glyphicon-pencil"></span>
@Html.ActionLink("Edit", "Edit", new { id = item.MovieID })
</label>
</div>
</div>
</td>
<td>
<div class="form-group">
<div class="btn-group" data-toggle="buttons">
<label class="pdsa-radiobutton btn btn-danger active">
<span class="glyphicon glyphicon-minus"></span>
@Html.ActionLink("Delete", "Delete", new { id = item.MovieID })
</label>
</div>
</div>
</td>
</tr>
</table>
</div>
@section scripts
<script>
$(function () {toastr.info("Click Movie for details") })
</script>
Thanks in advance
ViewBag.Title = " Movie Details";
<h2>Movie Details</h2>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-info btn-group-sm ">
<span class="glyphicon glyphicon-arrow-left"></span>
@Html.ActionLink("Return to Movie Menu", "Index")
</label>
</div>
<div class="table-responsive">
<table class="table table-striped">
<tr>
<th><b>Movie Name:</b> @*@Html.DisplayFor(model => model.MoviesName)*@</th>
<th><b>Movie Descritpion:</b> @*@Html.DisplayFor(model => model.MoviesName)*@</th>
<th></th>
</tr>
<tr>
<td>
<i> @Html.DisplayFor(model => model.MoviesName)</i>
</td>
<td>
<i> @Html.DisplayFor(model => model.Description)</i>
</td>
<td>@*<button class="btn btn-xs btn-info"><a style="color: white;" href="@Url.Action("Edit", new { id = Model.MovieID })">Edit </a></button>*@
</tr>
</table>
</div>
<p>
@Html.ActionLink("Add Actor To Movie", "Create", "Actor", new { movieID = Model.MovieID }, new { @class = "btn btn-primary" })
</p>
@if (Model.Actors != null)
<h5>@Model.MoviesName has @Model.Actors.Count() Actors</h5>
<div class="table">
<table class="table table-striped">
<tr>
<th>
Template: X is an actor in Y and played Z.
</th>
<tr>
<td>
@foreach (var mov in Model.Actors)
<p>
@Html.DisplayFor(modelItem => mov.ActorsName) is an actor in @Html.DisplayFor(model => model.MoviesName) and played @Html.DisplayFor(modelItem => mov.ScreenName).
@Html.ActionLink("Delete", "Delete", "Actor", new { id = mov.ActorID }, new { @class = "btn btn-danger btn-xs" })
@*<button class="btn btn-xs btn-info">@Html.ActionLink("Edit", "Edit", new { id = mov.ActorID })</button>*@
@*@Html.ActionLink("Edit", "Edit", "Actor", new { id = mov.ActorID }, new { @class = "btn btn-edit btn-xs" })*@
@*<button class="btn btn-xs btn-info"><a style="color: white;" href="@Url.Action("Edit", "Actors", new { id = mov.MovieID })"><span style="color:white;" class="glyphicon glyphicon-pencil"></span> Edit </a></button>*@
@*@Html.ActionLink("Edit Actors", "Edit", "Actor", null)*@
@*@Html.ActionLink("Edit", "Edit","Actor", null, new { @class = "btn btn-primary" })*@
</p>
</td>
</tr>
</table>
</div>
else
<p class="alert alert-info">No actors found!!</p>
<p>
@Html.ActionLink("Back to List", "Index")
</p>

How about save the way of sorting as a value in the cookie, When you need to go back the web page then you can read the data from the cookie.
Refer to:
http://msdn.microsoft.com/en-US/library/78c837bd(v=vs.80).aspx
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • How do I keep the page format from changing on my IPAD as I switch between pages

    How do I keep my page format from changing on my IPAD as I switch from page to page.

    Can you provide more information. Switching from page to page in what app? How if the format changing?

  • How do I keep a Pages 09 password protected file in iCloud?

    After uploading a Pages 09 password protected file from my laptop it shows as a page with the Pages 09 icon in the center (no visible text) in iCloud.  So far so good.  But once I open that doc using my iPhone, a task that as expected requieres entering the password, the protection seems to disapear and the file gets saved without the protection right in iCloud. The icon for the document changes from the Pages icon I described above to the text of the first page, just as a regular file, and if I try to open it back again entering the password is not requiered!
    How do I keep the file password protected?
    Thanks.  Ale

    Files stored in iCloud are stored locally as well as on some remote Apple server - just not on the desktop. You cannot keep the file on the desktop but you should be able to locate it in your Mobile Documents folder, make an alias, and put the alias on your desktop.
    The Mobile Documents folder is in your Library folder (hold option while selecting the Go menu in the Finder) and your Numbers documents are located in com~apple~Numbers

  • How do I keep my page from zooming in and out and my cursor moves all on it's own

    I have a mac pro and my page keeps zooming in and out all on it's own and my cursor just moves around with out me doing it, How do I keep my computer as it's suppose to be normal

    Mac Pro or MacBook Pro,What OSX,  if you have a track pad (MBP) check system preferences track pad zoom&scroll, or zoom options functions (slightly different depending which OSX) if a mouse holding control while using wheel will affect the screen, as well as swiping on a track pad.
    Also see the following:
    http://support.apple.com/kb/TS1449

  • How do I keep a page as my home page when dragging icon to left of URL to house image & confirming that I want it as home page works only for current session, so when Firefox next opened, I end up with some stupid search page which McAfee doesn't like?

    A couple of days ago, I connected to the Internet as usual & opened Firefox, only to be greeted by an almost blank screen with a Google-type search box in the middle & this message from McAfee:
    "Your default search settings have changed. This may pose a security risk. Would you like to restore them to McAfee Secure Search to provide a safer searching experience?"
    instead of my usual home page (BT Yahoo). I naturally clicked on the "Yes" option in the message, but rather than restoring my BT Yahoo home page, all that did was to insert the McAfee logo to the left of the search box in the top right-hand corner of the screen. The first time it happened, I had to search for the BT Yahoo page & then followed the standard procedure for setting it again as my home page. It worked only for that session: each time I shut down Firefox or restarted my computer after that, all I got was the blank "search page" & restoring the previous session was the only way to get back to BY Yahoo. How on earth do I make the home page setting permanent?
    As far as I'm aware, I have done nothing to alter my search settings. However, I am anything but computer-literate, so I may have done/pressed something without realising it, but trying to understand what is now happening is far beyond my limited IT skills.

    See McAfee support to find out how to disable that McAfee feature - that isn't part of the normal Firefox installation.

  • How do I keep multiple pages signed in?

    I am a past Pc user. Can someone please help me? Trying to figure out how to keep signed in to multiple sites at the same time. When I minimize a site and then hit safari to open a new one the same site just comes up. This was so easy on my pc. Thanks

    As markwmsn says, you just create a new window in Safari. In Mac OS X, things are pretty standard across all applications... if an app can support multiple windows, you create new windows through the File menu or by opening new documents (in a document-oriented app). Further, closing all windows does not usually close the app itself (though there are exceptions to that rule).
    Alternately, in many browsers (including Safari), you could create a new tab instead, using command-T (or New Tab in the File menu).

  • How Do I Keep Cover Page Blank?

    I'm running an old version (4.0.3) of Iphoto. I am trying to make a simple book - but do NOT want a picture or text on the cover. I can't seem to get this done. Any suggestions?
    IBook G4   Mac OS X (10.4.8)  

    Can you provide more information. Switching from page to page in what app? How if the format changing?

  • How do I lock my page zoom in new FF3.6?

    I just downloaded the new FF3.6. Big Mistake. I need page zoom to enlarge the page and keep the setting locked for future. The new FF3.6 will not stay locked. I have to manually zoom FF each time I open the browser. How can I keep my page zoom settings locked like I had before, on my trusty stable previous FF?

    If you need to adjust the font size on websites then look at:
    * Default FullZoom Level - https://addons.mozilla.org/firefox/addon/6965
    * NoSquint - https://addons.mozilla.org/firefox/addon/2592

  • How do I get the page to stop moving up and down so much?

    Re: Pages - Please tell me how I can keep the page from moving up and down so much.  It's irritating.  The page I'm writing on wants to bounce several times before it finally stops...like when you move the cursor, sometimes the page bounces.   Thanks for any help you can give.
    -R.J.

    R.J. Johnson wrote:
    Jerrold, good input about the scrolling to the end and the irritating "bounce."  This is what annoys me.  I bought a refurbished iMac 2 weeks ago that was made in May 2011 and I thought it would have Snow Leopard on it.  But it came with Lion.
    Also, yes, it comes with the Magic Mouse that is wireless.
    1,  So, I am just stuck with the Lion bounce?
    2.  PS Do you guys know how to have the Mail icon open on the Dock without the big mail window opening, too?  I do not set the Option for Mail to OPEN AT LOGIN because I hate having to close that big mail window every time I boot up the computer.
    R.J.,
    1. No matter what mouse you have, you will get a "bounce" if you bang into the limit. If you scroll gently into the limit and then back off, you will not see the same effect, or at least not the same degree. Check to see if your tracking speeds are similar with the two pointing devices. I think this will have more influence than whether the device is wireless or not.
    2. If you don't want anything to change in Mail when you boot up, I think you should just leave it open when you Shut Down the computer. With Lion, your Mail app should come back in the same state as when you Shut Down.
    Jerry

  • I am trying to delete pages I have crated in numbers, but can only see them in print preview. Without print preview I do not see them. How can I delete these pages, but keep others before and after?

    I am trying to delete pages I have crated in numbers, but can only see them in print preview. Without print preview I do not see them. How can I delete these pages, but keep others before and after?

    Hi Crushed,
    Numbers doesn't have pages. It has a canvas that holds objects such as tables and charts.
    Drag the objects from the bottom of the canvas onto the white space above. That will reduce the number of "pages" (sheets of paper) that will print.
    Regards,
    Ian.

  • How to show values with initial sort asc/desc in 11.5.10 iProcurement page?

    (Logged Bug 12902576 with OAFramework DEV, but OAF DEV closed the bug and advised to log the issue here in the forum)
    How to have values sorted in ascending order when user first navigates to the page?
    Currently the values are unsorted, and are only sorted after the user clicks the column heading to sort the values. We expect the users should not have to click the column heading, but instead that the values should be sorted in ascending order when the user navigates to the page. This issue occurs on an OAFramework based page in iProcurement application.
    PROBLEM STATEMENT
    =================
    Receipts and Invoices are not sorted in iProcurement Lifecycle page even after implementing personalization to sort ascending on Receipt Number and Invoice Number. Users expect the receipts and invoices to be sorted but they are not sorted.
    STEPS TO REPRODUCE
    1. Navigate to iProcurement
    2. Click the Requisitions tab
    3. Search and find a requisition line that is associated to a Purchase Order having multiple receipts and multiple invoices.
    4. Click the Details icon to view the lifecycle page where the receipts and invoices are listed
    - see that the receipts are not sorted, and the invoices are not sorted
    5. Implement personalization to sort in ascending order for Receipt Number and for Invoice Number. Apply the personalization and return to page.
    - the receipts and invoices are still not sorted.
    IMPACT
    Users need the receipts and invoices sorted to make it easier to review the data. As a workaround, click the column heading to sort the results
    Tried workaround suggested by OAFramework DEV in Bug 12902576 but this did not help.
    TESTCASE of suggested workaround
    NAVIGATION in visprc01
    1. Login: dfelton / welcome
    2. iProcurement responsibility / iProcurement Home Page / Requisitions tab
    3. Click the Search button in the upper right
    4. Specify search criteria
    - Remove the 'Created by' value
    - Change 'Last 7 Days' to 'Anytime'
    - Type Requisition = 2206
    5. Click Go to execute the search
    6. Click the Requisition 2206 number link
    7. Click the Details icon
    8. In the Receipt section, click the link 'Personalize Table: (ReceivingTableRN)'
    9. Click the Personalize (pencil) icon
    10. Click the Query icon for Site level (looks different than the screenshots from OAFramework team, because this is 11.5.10 rather than R12
    - Compare this to the Table personalization page show in the reference provided by OAFramework team -
    http://www-apps.us.oracle.com/fwk/fwksite/jdev/doc/devguide/persguide/T401443T401450.htm#cust_persadmin_editperprop
    11. See on the Create Query page
    Sorting
    No sorting is allowed
    The Query Row option becomes available in personalize after setting the Receipt Number row to Searchable. However, even after clicking the Query icon to personalize, it is not possible to specify sorting. There is a Sorting heading section on the personalization page, but there is also a statement: No sorting is allowed
    The workaround mentioned by OAFramework team in Bug 12902576 does not work for this case
    - maybe because this is 11.5.10 rather than R12?
    - maybe similar to Bug 8351696, this requires extension implementation?
    What is the purpose of offering ascending/descending for Sort Allowed if it does not work?
    Please advise if there is a way to have the initial sort in ascending order for this page.

    I´m sorry that you couldn´t reproduce the problem.
    To be clear:
    It´s not about which symbol should seperate the integer part from the fraction.
    The problem is, that i can´t hide the fraction in bargraph.
    The data im showing are integers but the adf bar graph component wants to show at least 4 digits.
    As I´m from germany my locale should be "de" but it should matter in the test case.
    You can download my test case from google drive:
    https://docs.google.com/open?id=0B5xsRfHLScFEMWhUNTJsMzNNUDQ]
    If there are problems with the download please send me an e-mail: [email protected]
    I uploaded another screenshot to show the problem more clear:
    http://s8.postimage.org/6hu2ljymt/otn_hide_fraction.jpg
    Edited by: ckunzmann on Oct 26, 2012 8:43 AM

  • HOW DO I SCAN MULTIPLE PAGES OF A DOCUMENT AND KEEP IT IN ONE DOCUMENT ON A HP PHOTOSMART 5510

    HOW DO I SCAN MULTIPLE PAGES OF A DOCUMENT AND KEEP THAT DOCUMENT AS ONE

    Hello @MYBOU2 ,
    Welcome to the HP forum.
    What you are asking should not be too hard. The key factor right now is: what is your operating system?
    The process is different on a Mac compared to a Windows computer.
    This link explains how to do what you want with windows 7.
    Scan from Windows 7 With the Full Feature HP Software for HP Multifunction Printers
    Please let me know your OS and I will get more specific instructions.
    Aardvark1
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!

  • Hi, how can I keep the same zoom level for all the pages I view in Safari and even when I close and open it.  Indeed with a 27 inch Imac I have a lot of space, most of the websites are built for smaller resolutions  and my sight is dropping !   Thx

    Hi, how can I keep the same zoom level for all the pages I view in Safari and even when I close and open it.  Indeed with a 27 inch Imac I have a lot of space, most of the websites are built for smaller resolutions  and my sight is dropping !   Thx

    Hi, how can I keep the same zoom level for all the pages I view in Safari and even when I close and open it.  Indeed with a 27 inch Imac I have a lot of space, most of the websites are built for smaller resolutions  and my sight is dropping !   Thx

  • I am exporting a Pages document to Epub and Pages is compressing my jpg images.  How do I keep the original jpg size during the export to epub process?

    I am exporting a Pages document to Epub and Pages is compressing my jpg images (I think to 72 dpi from original 600 dpi). 
    How do I keep the original jpg size during the export to epub process?

    We are still trying learn how to use Pages to build ePub documents with high resolution graphics that will expand clearly when they are tapped. Very large screen shots are my example here.

  • How do I Keep the "zoom" size setting the same each time I open Safari and from web page to web page?

    I have a 27" iMac when I open Safari the web page is only 1/3 the size of the full screen Safari window. I know how to ZOOM in on the web page! My question is, How do I keep this ZOOM setting for all web pages and each time I open Safari up?

    Sorry, but that's not possible.
    An alternative might be to use Zoom in System Preferences > Accessibility
    Or try a different screen resolutioin in System Preferences > Displays > Scaled

Maybe you are looking for

  • Using Cover Flow, then resizing window

    I love cover flow for my finder windows, but every time I resize a window, it automatically makes the cover flow section increase in size. This drives me nuts; I'm always trying to increase the window size so I can see more options available to me in

  • Oracle Beehive REST API - Instant Message

    Hi all, We need to implement a chat client using Beehive's REST API. Somehow, we encounter a problem when calling comb/v1/d/imsg/{name} service. We have tried to enter many possible value for {name} like userID, collabID, random string, but all of th

  • Process code for Idoc BANK_CREATE01 and BANK_CHANGE01

    hi, I  want to create partner profile  for Idoc BANK_CREATE01 and BANK_CHANGE01 standard Idocs. But in transaction we64 , i am not finding the inbound process code  for it. So di i have to create a process code for it?? If yes , how do i create it an

  • Multiple Word Search

    Does anyone know how i can search a coloumn using multiple words without using string tokenizer I get all the values in the table everytime as it searches using " " unless you enter a string in every section. If you just want to search for one word i

  • After creating Database???

    I have generated script file using database assistant. I create database using those scripts. MY database is working fine except asking to run pupbld.sql. Somebody told me that it doesn't harm you. Should I run other scripts or not like catproc.sql c