当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > 后台更新DataTable行内容的方法

ASP.NET
Check Your Internet Connection With C#
Essential .NET读书笔记
可用来显示空值的时间选择控件3
学习Keny boy sps区域列表的管理入口程序
[译]Visual Basic 2005在语言上的增强(十)应用程序级别事件
什么时候应该使用 ==?什么时候应该使用 Equals?
“String.Equals(string)”和“==”那个快?
应用ADO.net得到系统表信息
不会被其他窗体遮挡的抓图,使用API的PrintWindow函数
关于.net下服务安装
水晶报表4.6的使用示例
超大正整数加法与乘法最笨方法实现
实现web页面的局部刷新
动态生成带事件的MsFlexGrid
一些codedom的资料。
WML教程3:任务与导航-赋值与数据交换
WML教程7:WML的事件
WML教程10:分组选择控件(Optgroup)和复杂实例
WML教程5:任务和任务屏蔽
VS.NET安装部署深入研究

ASP.NET 中的 后台更新DataTable行内容的方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 139 ::
收藏到网摘: n/a


这几天一直在找绑定后后台修改datatable行这方面的代码,发现很少,但是又不得不实现这样的功能,通过查帮助,自己解决了:)
我是将datatable绑定到listbox上,通过修改datatable来修改listbox值listbox1.BeginUpdate(); // Stop the ListBox from drawing while items are added.DataTable dt;int IndexNum=listbox1.SelectedIndex;dt=(DataTable)listbox1.DataSource;DataRow custRow = dt.Rows[IndexNum];custRow.BeginEdit();custRow[0] = IndexNum;custRow[1]="after modify";custRow.EndEdit();dt.AcceptChanges();listbox1.EndUpdate();// End the update process and force a repaint of the ListBox.listbox1.Update();listbox1.BeginUpdate(); // Stop the ListBox from drawing while items are added.DataTable dt;int IndexNum=listbox1.SelectedIndex;dt=(DataTable)listbox1.DataSource;DataRow custRow = dt.Rows[IndexNum];custRow.BeginEdit();custRow[0] = IndexNum;custRow[1]="after modify";custRow.EndEdit();dt.AcceptChanges();listbox1.EndUpdate();// End the update process and force a repaint of the ListBox.listbox1.Update();