MVCContrib grid and send back using model binder

The content of my MVCContrib grid comes from a model in a strongly typed view. When a message is created, the contents of the grid are not in the model object when it returns to the controller. I see that this is because the grid is displayed as a table with text in cells. Is there something I can do so that when a message occurs, the list of data that I sent to the grid is returned in the message?

+3
source share
2 answers

You can use TempData to save this server side information. Information in TempData will be saved for a single request. I really don't like this option.

Can you refill your model from db? If the user does not change the information, why do you need to return all the same immutable data? Just take it again from where you got it.

+2
source

If you want to recreate the model as it was serialized in the grid, you will need to embed the correctly named form elements in the grid (or, possibly, outside the grid), and in the same form as the button containing the button, sending it back to the action, where you want your model recreated.

, , , __VIEWSTATE, MVC ( " , IDE " ).

, , .

  • .
  • TryUpdate .

( , ? ?), , (.. ), , MVC .

+1

Source: https://habr.com/ru/post/1713406/


All Articles