Nazmul Hossain
Nazmul Hossain

Reputation: 2085

Both create and list in the same view MVC4?

I am new to MVC4. I know basic CRUD functionality in MVC, but how can I achieve both create and list in the same view? Like after a user creates data the user will automatically be redirected to the same view and view the list of data.

Upvotes: 1

Views: 592

Answers (1)

Vivek Jain
Vivek Jain

Reputation: 3889

You may use partial views to accomplish this. Create the create / edit pages the same way as you do and below the form you may render a partial view that would render the list with even edit / delete buttons.

Alternatively, you may pass both the form data (in case of edit) and the list data to a view to render there.

I would suggest you to use the partial views approach as it would simplify the view and the partial view can be reused on some other page also.

Please take this as a starting point and not as a follow-it-blindly solution.

Upvotes: 2

Related Questions