Display Data In Webgrid And Delete Multiple Rows By Using Checkboxes In MVC 5 Application

INTRODUCTION

In this article, I am explain How to Display Data In Webgrid And Delete Multiple Rows By Using Checkboxes In MVC 5 Application.

CREATE NEW PROJECT.

Go to File > New > Project > Select asp.net web application (with .NET Framework 4.5) > Enter Application Name > Click OK > Select Empty MVC Template > OK

Create Table.

DATA TABLE

Add Entity data model.
In previous articles I explained how to add entity data model. here

ADD A NEW CONTROLLER.

Go to Solution Explorer > Right Click on Controllers folder form Solution Explorer > Add > MVC5 Controller- Empty > Enter Controller name Home > Add.

ADD NEW ACTION INTO YOUR CONTROLLER FOR DISPLAY DATA IN WEBGRID.

Here I have added "List" Action into "Home" Controller. write this following code. 

LIST ACTION

ADD VIEW FOR for the LIST ACTION

Right Click on Action Method (here right click on form action) > Add View... 

ADD VIEW

Rebuild solution before add view.

Write following code into List view.

LIST VIEW


ADD ANOTHER ACTION INTO YOUR CONTROLLER FOR DELETE MULTIPLE ROWS AT ONCE.

Here I have added "Delete" Action into "Home" Controller. 
write this following code .

DELETE ACTION

RUN APPLICATION(CTTL + F5).

WEBGRID

2 comments

Hi, this is really an useful article. I followed this but on click of delete button it doesn't post the data to the controller. is there any issues in this article?

Reply

Hello, there is no issue in article. its working fine. Please check your controller and action name in your view page.

Reply

Post a Comment