Welcome

首页 / 脚本样式 / ExtJS / ExtJS与.NET结合开发实例(Grid之批量删除篇)

ExtJS与.NET结合开发实例(Grid之批量删除篇)2010-12-12 cnblogs cmsoft上接ExtJS与.NET结合开发实例(Grid之数据显示、分页、排序篇),在此基础 上实现批量删除功能。

实现的步骤如下:

1. 用WebService实现 删除的功能(上篇有一园友提出用WebService实现,这里顺便说一下,取数据源 也可以用WebService,大家可以参考删除的WebService自行实现,我这里就不在 累述了)

新建一WebService文件,命名为:DeleteProject.asmx

代 码如下:

DeleteProject.asmx.cs

1using System;
2using System.Data;
3using System.Linq;
4using System.Web;
5using System.Collections;
6using System.Web.Services;
7using System.Web.Services.Protocols;
8using System.ComponentModel;
9using System.Xml.Linq;
10using BusinessObject.Projects; //dbml文件的引用
11using Database;
12namespace Web.Projects.OperProjects
13{
14 /**//// <summary>
15 /// Summary description for DeleteProject
16 /// </summary>
17 [WebService (Namespace = "http://tempuri.org/")]
18 [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
19 [ToolboxItem(false)]
20 // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
21 // [System.Web.Script.Services.ScriptService]
22 public class DeleteProject : System.Web.Services.WebService
23 {
24
25 [WebMethod]
26 public bool DelProject(string strProjects) //这里需要返回删除是否成功给 ExtJS调用
27 {
28 bool result = false;
29 try
30 {
31 ProjectBaseInfoDataContext db = new ProjectBaseInfoDataContext();
32 var projects = from p in db.PROJECT_BASE_INFOs
33 where strProjects.IndexOf (p.PROJECT_NO) > 0
34 select p;
35 db.PROJECT_BASE_INFOs.DeleteAllOnSubmit (projects);
36 result = true;
37 }
38 catch {
39 result = false;
40 }
41
42 return result;
43 }
44 }
45}
46