Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The MVC framework does not really favour one method of data access over another. Obviously one of the key advantages of MVC is its improved testability so it makes sense to structure your code in such a way that your controllers can be decoupled from data access logic for unit testing. The easiest way to do this is via the repository pattern, which you can implement with ADO.NET.</p> <p>To render tabular data you would be better off doing this with a foreach loop in a view rather than using a partial. This can get messy if there is complex logic but this can be cleaned up by the use of HTML helpers. See Rob Conery's excellent article on <a href="http://blog.wekeroad.com/blog/asp-net-mvc-avoiding-tag-soup/" rel="nofollow noreferrer">avoiding tag soup</a> for some pointers on this.</p> <p>I think the best approach to row editing would be to have each row edit make an AJAX request to an edit action so that you do not need to refresh all the data. As MVC handles the binding of action parameters seamlessly this is very easy to do. You can have a specific action for this that sends a status message back for user feedback. I'd roll your own functionality for this as it is very easy to do.</p> <p>For refresh all the data you I've found the simplest approach is to use a bool? isPartial parameter on your view, when it is not defined or false you render a complete view, when it is present and true you render a partial instead. Then you can call the same action normally on first request and then send through isPartial = true when making an AJAX request. You can then use jQuery to update the HTML of the table as complete block. This is quicker than returning JSON and parsing this client side.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload