All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
php5的simplexml解析错误_php资料_编程技术
SELECT,INTO,和,INSERT,INTO,SELECT,两种表复制语句_mssql学习_编程技术
教你IIS6的PHP最佳配置方法_[PHP教程]
ASP.NET技巧:DataGridView,的分页处理_.net资料_编程技术
SQL数据库高级教程:学习 SQL Alias(别名)_[SQL Server教程]
C#多线程:不同线程之间通过事件委托封送调用方法_[Asp.Net教程]
C#网络应用编程基础练习题与答案(十)_.net资料_编程技术
经典:10个重要的PHP网络信息函数说明_php资料_编程技术
delphi MapViewOfFile函数将映像文件映射到进程
SQL Server中存储过程的安全问题_[SQL Server教程]
Reading number is top 10 pictures
为什么别人说你是疯子
Play for Free show breast in a world of ice and snow
新版武松打虎
去瑜伽会所面试的经过
8090后结婚的各种XX事
奇趣的世界记录3
The money of more than 100 countries and regions13
Fat bird to fly
中国处女图鉴2
Sora aoi possession of boudoir1
Download software ranking
I'm come from Beijing1
Love the forty days
传奇私服架设教程
Ashlynn Video3
Unix video tutorial19
Tram sex maniac 2 (H) rar bag5
天龙八部最新服务端
Boxer's Top ten classic battle1
Prostitutes diary
DreamWeaver8
delv published in(发表于) 2014/1/8 7:02:03 Edit(编辑)
ASP.NET技巧:DataGrid的多行提交_[Asp.Net教程]

ASP.NET技巧:DataGrid的多行提交_[Asp.Net教程]

ASP.NET技巧:DataGrid的多行提交_[Asp.Net教程]

尽管ASP.NET DataGrid是众所周知非常好的表格控件,不过,提起DataGrid的编辑功能,我们却不敢恭维了,就拿DataGrid的数据提交功能来说,的确存在很大的问题:在DataGrid中,每编辑一行就要提交一行,即所谓“单行编辑、单行提交”,这样的话,如果编辑的行数过多,不仅用户操作繁琐,还会造成对服务器的频繁访问,极大降低系统效率。


当然了,有一种借尸还魂的解决方法,那就是把所要编辑的内容转到其他的页中在TextBox中进行编辑。不过,仔细想想,这种方法难道不是自己在骗自己吗,还有在Grid中我们编辑的时候总不能老是用Tab键来实现Grid(TextBox)之间的跳转吧,如果响应回车事件,那么需要程序员浪费很大的精力来开发。


如何解决上述问题呢?下面我向大家推荐一个我正在使用的国产DataGrid:SmartGrid(天空软件站可以下载:http://www.skycn.com/soft/23547.html ),这个控件我已经用了好长的时间了,现在来同大家探讨一下SmartGrid的多行提交的方法:SmartGrid并没有DataGrid中的那些按钮列而是整个的表单只有一个提交按钮,无论你更改了一行或者是多行都可以一次性的提交,下面来随便看点例子:


实例:


上图中是一个比较好的编辑的例子,例子显示,你可以编辑多行也可以编辑一行,然后一起进行提交。


代码:


修改按钮的代码:


private void btonSave_Click(object sender, System.EventArgs e)


{


this.DataGrid1.ReadOnly = false;//进入编辑


this.DataGrid1.AllowAdd = true;//允许添加


this.DataGrid1.AllowDelete = true;//允许删除


}


此段代码是smartgrid的独有的属性你可以设添加删除 编辑 的各种的功能


保存按钮的代码:
private void Button2_Click(object sender, System.EventArgs e)


{


DataTable t = (DataTable)this.SmartGrid1.DataSource;


this.sqlDataAdapter1.Update(t);


t.Clear();


this.sqlDataAdapter1.Fill(t);


this.SmartGrid1.DataSource = t;


}


这是整体的把数据提交到数据库中,这种做法适合大数据量的情况


还有一种是数据逐行的提交到服务器


代码:


private void btonSave_Click(object sender, System.EventArgs e)


{


DataTable tb=(DataTable)this.SmartGrid1.DataSource;


SqlParameter[] parameters=new SqlParameter[5];


foreach(DataRow dr in tb.Rows)


{


parameters[0]=new SqlParameter("@customerId",""+dr[1]+"");


parameters[1]=new SqlParameter("@companyName",""+dr[0]+"");


parameters[2]=new SqlParameter("@contactName",""+dr[2]+"");


parameters[3]=new SqlParameter("@contactTitle",""+dr[3]+"");


parameters[4]=new SqlParameter("@address",""+dr[4]+"");


//EamPd 是类Execute是执行存储过程的函数parameters是存储过程所需要的参数


EamPd.Execute("CreatLayer",parameters);


}


}


来源:网络







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.