SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2009
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MVC 3 RedirectToAction Querystring

    I need to go back to the list of notes per patient Id after the create method.

    Code Csharp:
     public ActionResult Create(Notes note)
            {
                if (ModelState.IsValid)
                {
                    db.Notes.Add(note);
                    db.SaveChanges();
                    return RedirectToAction("Index");  
                }
     
     
                return View(course);
            }

    how do you add a querystring to the RedirectToAction to get back to the list of notes on the Index per patient Id? It gives me an error asking for a patientId value based on the fact I have an Index(int patientId) in the Controller.

    thanks

  2. #2
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Use the overload in the RedirectToAction. Something like this:
    Code Csharp:
    return RedirectToAction("Index", note.PatientID);

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2009
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see what you mean...thanks for the help


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •