Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7876375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:09:27+00:00 2026-06-03T03:09:27+00:00

I have a controller Contracts and 3 GET methods: All, Focus, which contains grid,

  • 0

I have a controller “Contracts” and 3 GET methods: “All”, “Focus”, which contains grid, and “Edit” for editing, and one POST method: “Edit”.
Users can access to Edit from any grid by using button. But after POST executed, i want to redirect them to action that send request.
For example:

  1. open “Focus” grid
  2. select row
  3. clicked edit
  4. make changes, and click save
  5. finally redirect to “Focus” grid (!)

or

  1. open “All” grid
  2. select row
  3. clicked edit
  4. make changes, and click save
  5. finally redirect to “All” grid (!)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:09:28+00:00Added an answer on June 3, 2026 at 3:09 am
    public ActionResul All()
    {
      var items=dbContext.Items;
      return View("All",items);
    }
    

    in the All View you will have the grid with the data. Selecting a record from the Grid and clicking Edit will take you to the second Action method for Edit.

    You may pass a some flag when calling the edit method here. You may add that when you build the edit link like this

    @Html.ActionLink("Edit","Edit","Item",new { @id=item.Id, @from="all"},null)
    

    So my Edit will have a querystring key “from” with a value “all“

    Same way,in your the View for your Focus, you may pass a different value

    @Html.ActionLink("Edit","Edit","Item",new { @id=item.Id, @from="focus"},null)
    

    Now the Edit Action method, You read the parameter and set it as the property value of our edit view model. you may want to add this property to your ViewModel.

    public ActionResult Edit(int id,string from)
    {
      EditItemViewModel item=GetItem(id);
      item.From=from;      
      return View(item);
    }
    

    and this View will have the edit form. We will keep the value of From inside a form element so that we can use that on the form post.

    @model EditItemViewModel 
    
    @using(Html.BeginForm())
    {
       @Html.HiddenFor(m => m.Id);
       @Html.TextBoxFor(m => m.ItemName)
       @Html.TextBoxFor(m => m.ItemDesc)
       @Html.HiddenFor(m => m.From)
       <input type="submit" value="Update" />
    }
    

    Where user can edit and submit it again . you handle that in the HttpPost Edit action method. Check the From property value and decide where to redirect after saving

    [HttpPost]
    public ActionResult Edit(EditItemViewModel model)
    {
      if(ModelState.IsValid)
      {
        //Save data 
       if(model.From=="all")
           return RedirectToAction("All");
       else
           return RedirectToAction("Focus");
      }
      return View(model);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a new MVC3 project with one Controller called PublicController.cs which contains 4
I have a controller which allows only POST for certain actions: static allowedMethods =
I have my own inherited App.Controller from Mvc.Controller which then all of my controllers
Hi guys i have controller which returns a partial view, the controller is called
I have a tab-bar and navigation controller application (like Youtube app or Contacts app).
I have an entries controller that allows users to add contact information the website.
I have controller with action new , and I want it to create ActiveRecord::Base
I have controller PlayerController and actions inside: View , Info , List . So
I have Controller: [MySite]\Controllers\DistributionTools\TrackingChannelsController.cs [HttpPost] public void InitTcFirstPageView() { var model = new TcFirstPageModel
I have @Controller @RequestMapping(value=core/*) public class CoreController { public static String exceptionOccurredView = /core/exceptionOccurred;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.