0
votes

I'm new to MVC, and I'm having a hard time with a task that would be pretty easy with classic ASP.net.

I have a gridView that has a checkbox in each row, and I want a functionality where the user ticks the checkboxes of the rows he wants, clicks some button on the page and the selected rows would be sent to the server.

In normal ASP, the whole page is sent so its easy to check the gridView rows and the checkbox in each row, but in MVC the whole point is the Controller class not knowing about the details of the GUI, so how do I implement such a thing in MVC?

1
You have a gridview in MVC? - MikeSmithDev
Is that bad? How else am I supposed to show table data? - Avi Sasson
You are talking about GridView right? - MikeSmithDev
Yeah, the Drag&Drop ASP GridView... - Avi Sasson
I'm getting the feeling I'm doing something really wrong here. - Avi Sasson

1 Answers

0
votes

You don't use server-side controls like that in MVC. GridView is for web forms framework. These two SO posts cover similar issues:

  1. grid controls for ASP.NET MVC?
  2. How to use gridView in Mvc without adding form runat server?

So there are a lot of examples in that post. I've used jQuery DataTables without issues. You build your table with a loop and then apply the DataTable to turn it into a searchable, sortable, filterable grid.

Walking through a tutorial, like the one at http://www.asp.net/mvc will get you familiar with how MVC works and show you how to update your models.

Update: I have no idea how your back-end is configured, so this is a shot-in-the-dark... but one easy way to get started is like this:

  1. Once you have your model, go to your Controllers folder and right click -> Add -> Controller
  2. Name it
  3. Under Template choose "MVC controller with read/write actions and views, using Entity Framework"
  4. Choose your model class
  5. Choose your data context
  6. Click Add

This will create a controller with all your CRUD operations and the related views. Poking around that should help... especially the Edit.cshtml.