http://csharp-video-tutorials.blogspo...
Link for csharp, asp.net, ado.net, dotnet basics, mvc and sql server video tutorial playlists
http://www.youtube.com/user/kudvenkat...
In this video, we will discuss deleting multiple rows in an asp.net mvc application.
We will be using table tblEmployee for this demo. Please refer to Part 62, if you need SQL script to create and populate this table.
We want to provide a checkbox next to every row, to enable users to select multiple rows for deletion.
Step 1: Create an empty asp.net mvc 4 application.
Step 2: Generate ADO.NET entity data model from database using table tblEmployee. Change the entity name from tblEmployee to Employee. Save changes and build the application.
Step 3: Add HomeController with the following settings.
a) Controller name = HomeController
b) Template = Empty MVC controller
Setp 4: Add "Shared" folder under "Views", if it is not already present. Add "EditorTemplates" folder, under "Shared" folder. Right click on "EditorTemplates" folder and "Employee.cshtml" view with the following settings
View name = Employee
View engine = Razor
Create a strongly-typed view = checked
Model class = Employee (MVCDemo.Models)
Scaffold Template = Empty
and finally click "Add"
Step 5: Copy and paste the following code in Employee.cshtml view
@model MVCDemo.Models.Employee
[tr] [td] [input type="checkbox" name="employeeIdsToDelete" id="employeeIdsToDelete" value="@Model.ID" /] [/td] [td] @Model.Name [/td] [td] @Model.Gender [/td] [td] @Model.Email [/td]
[/tr]
Step 6: Copy and paste the following code in HomeController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MVCDemo.Models;
namespace MVCTest.Controllers
{ public class HomeController : Controller { private SampleDBContext db = new SampleDBContext(); public ActionResult Index() { return View(db.Employees.ToList()); } [HttpPost] public ActionResult Delete(IEnumerable[int] employeeIdsToDelete) { db.Employees.Where(x =] employeeIdsToDelete.Contains(x.ID)).ToList().ForEach(db.Employees.DeleteObject); db.SaveChanges(); return RedirectToAction("Index"); } }
}
Setp 7: Right click on the Index() action and add "Index" view with the following settings.
View name = Index
View engine = Razor
Create a strongly-typed view = checked
Model class = Employee (MVCDemo.Models)
Scaffold Template = Empty
and finally click "Add"
Setp 8: Copy and paste the following code in Index.cshtml view
@model IEnumerable[MVCDemo.Models.Employee]
[div style="font-family:Arial"]
[h2]Employee List[/h2]
@using (Html.BeginForm("Delete", "Home", FormMethod.Post))
{
[table border="1"] [thead] [tr] [th] Select [/th] [th] Name [/th] [th] Gender [/th] [th] Email [/th] [/tr] [/thead] [tbody] @Html.EditorForModel() [/tbody]
[/table]
[input type="submit" value="Delete selected employees" /]
}
[/div]
In our next video, we will discuss providing a "SELECT ALL" checkbox to select and de-select all rows.
Make sure to replace [ with LESSTHAN and ] with GREATERTHAN symbol.
asp.net core docker Part 65 Deleting multiple rows in mvc | |
167 Likes | 167 Dislikes |
65,609 views views | 524K followers |
Education | Upload TimePublished on 30 Jul 2013 |
Related keywords
wcf vs web api,ado.net core,sql server management studio,webkinz,webadvisor,mvc 4 shot,craigslist nj,mvc4 rumors,wcf one piece,asp.net core 3,ajax players,weber grill parts,webtoon,tutorials by hugo,csharp corner,mvc design pattern,asp.net machine account,servers for minecraft,asp.net core dependency injection,ado.net tutorial,mvc 4 news,services angular,ajax ontario,delete all messages,asp.net mvc tutorial,delete con inner join,asp.net cos'è,csharp assembly,tutorialspoint python,sql join,services briefcase,asp.net core web api,ajax jquery,wccftech,craigslist ny,mvc3 クソル,delete tweets,asp.net zero,mvc3 フランク,csharp foreach,server memes,mvc 4 download,mvc4 vs mvc5,sql date format,services online,delete laravel,chase,serverless architecture,server resume,wcf c#,server books,tutorialspoint javascript,mvcc connect,ado.net mysql,services technologies gps,mvc3 エンディング,ajax deadpool,server jobs,mvc 4 .net,cvs,website,mvc tutorial,costco hours,mvc3 ダンテ,wcf service application,tutorialspoint spring,serverless,wcf soap,mvc3 キャラランク,mvc3 ドーマムゥ,wcf cat,deleted,cool math games,wcf test client,delete branch git,services & training hse colombia sas,servicestack,citibank,asp.net core identity,sql union,ajax parking,sql database,asp.net core logging,delete instagram account,mvconnect,cunyfirst,asp.net guida,wcf nba,csharp download,wcfi foundation,mvc 4 leak,csharp online,mvc 4 evo 2019,wcf authentication,mvc3 成歩堂,tutorials near me,http://asp.net,server 2019,chernobyl,ado.net descargar,web of dreams,serverminer,ajax cleaner,ado.net visual studio 2019,webassign,ado.net vs entity framework,mvc 4 reddit,ado.net visual studio 2017,csharp list,delete mysql,sql like,asp.net mvc,asp.net core tutorial,sqlite,wcfm,ajax roster,mvc architecture,delete oracle,http://ado.net,asp.net core mvc,ajax soccer,server hosting,wcfi,delete table,ajax dish soap,capital one,server rack,tutorialspoint html,delete facebook,csharp interface,craigslist,mvc 4 tutorial,delete sql,webroot,tutorialspoint reactjs,ajax request,wcf dragon ball,asp.net core 2.2,tutorialspoint python 3,sql developer,webster,services transmission company sas,sql group by,asp.net core signalr,services manager,mvc framework,ajax paving,mvc near me,delete column sql server,mvc4 vaccine,deletereas,mvc 4 install,tutorialspoint spring boot,mvc 4 runtime,mvc map,csharp online compiler,delete repository github,asp.net download,sql between,ado.net c# pdf,mvc3 デッドプール,services tag dell,wcf 2019 nba,csharp switch,ado.net ventajas y desventajas,csharpstar,wcf tutorial,mvc3 サントラ,tutorialspoint,ajax meaning,csharp-video-tutorials.blogspot,tutorials dojo,central park 5,csharp string format,ado.net c#,asp.net core github,server status,ajax fc,server jobs nyc,asp.net core swagger,sql formatter,credit karma,services group,server error in '/' application,services windows,asp.net core 3.0,mvc 4 roster,sql injection,tutorialspoint c#,wcf ria services,calculator,ado.net entity data model,sql insert,tutorialspoint tableau,mvc30a,services google play apk,mvc3 バージル,sqlyog,asp.net core 3 release date,sql server,server job description,tutorials by a,servicenow,webcam,mvc hours,webmd symptom,csharp array,csharp enum,ajax call,asp.net core 2. guida completa per lo sviluppatore,mvc3 ウェスカー,asp.net core,server pro,mvc3 ps4,server status ffxiv,cheap flights,webcrims,asp.net core hosting,services sas,tutorialspoint java,mvc 4 evo,tutorialspoint java compiler,webmd,csharp to json,college football,ado.net dataset,mvc 4 kappa,csharp dictionary,cnn,website builder,tutorialspoint sql,asp.net web api,server side rendering,weber grills,sql server 2017,delete postgresql,mvc3 センチネル,tutorialspoint spark,mvc nj,ado.net oracle,asp.net core download,csharp to vb.net,delete column oracle,delete facebook account,webster bank,webstaurant,mvc30,tutorialsystems,ajax post,mvc4-mb/cpu-mtr,services fms publish announcement,services.msc no abre,ajax jersey,csharp operator,asp.net core razor pages,server duties,asp.net core environment variables,mvc32,deletereo,mvc 4 release date,csharp random,century 21,mvc3 セリフ,services consultores,services consulting,mvcsd,services.msc,mvcsc,ado.net pdf,asp.net core configuration,ajax marvel,sql update,asp.net tutorial,mvc medical,ado.net entity data model visual studio 2019,wcfs international curriculum,mvc 4 e3,mvc2,ado.net entity data model visual studio 2017,chase online,wcf api,costco,server jobs near me,webex,sql meaning,sql tutorial,sql commands,delete element array javascript,ado.net entity framework,ajax tavern,tutorialsteacher,ajax javascript,services desk,ajax greek,csharp tutorial,mvc pattern,ado.net sql server,ado.net connection,asp.net identity,mvcu,mvc3 ジル,asp.net core middleware,wcf web service,mvc3 フェニックス,mvc301,mvc webadvisor,web store,mvcc,webmail,mvci,mvc40h,mvctc,
Không có nhận xét nào:
Đăng nhận xét