zoukankan
html css js c++ java
控件與資料綁定、保存控件值變更的資料、撤消未保存資料的方法
控件與資料綁定過程:
1.得到被綁定資料
2.設定表單的資料來源
3.建立Binding
4.將Binding與控件相關聯
示例代碼:
/**/
///
<summary>
///
從數據庫得到資料的表
///
</summary>
DataTable dtbUserFavorite
=
new
DataTable();
/**/
///
<summary>
///
定義資料來源
///
</summary>
BindingSource dtsUserFavorite
=
new
BindingSource();
/**/
///
<summary>
///
綁定控件方法
///
</summary>
private
void
BindingControl()
{
try
{
//
1、
從數據庫讀取資料
dtbUserFavorite
=
FrontRemoting.Remoting.GetUserFavoriteDataTable(ClbFrontInfo.clsFrontInfo.UserKey,
this
.Tag.ToString(),
"
//*[Visible=1]/@name
"
,
"
//@filterUser
"
, ClbFrontInfo.clsFrontInfo.UserGUID);
//
2、
建立綁定源並設定為從數據庫得到的資料
dtsUserFavorite.DataSource
=
dtbUserFavorite;
//
3、
建立綁定new binding(“控件被綁的屬性”,綁定源,“對應綁定源中的值”)
Binding bdMsgIsMsn
=
new
Binding(
"
Checked
"
, dtsUserFavorite,
"
ufMsgIsMsn
"
);
//
4、
綁定控件(
CheckBox)
chkMsnLike.DataBindings.Add(bdMsgIsMsn);
}
catch
(Exception ex)
{
throw
ex;
}
}
保存控件值變更的資料過程:
1、結束編輯
2、得到變更
3、保存資料
示例代碼:
//
1、
結束編輯
dtsUserFavorite.EndEdit();
//
2、
得到變更
DataTable dtbMsgUserFavoriteChange
=
dtbUserFavorite.GetChanges();
//
3、
保存變更
BoUserFavorite.boUserFavorite.UpdateDataTable(dtbMsgUserFavoriteChange,
this
.Tag.ToString(), ClbFrontInfo.clsFrontInfo.UserKey);
撤消未保存資料:
示例代碼:
dtsUserFavorite.CancelEdit();
——宽田 著——
查看全文
相关阅读:
单元测试的那点事儿
centos 下载为firefox安装flash插件
ubuntu lamp(apache+mysql+php) 环境搭建及相关扩展更新
PHP源代码数组统计count分析
fgetcsv函数的“陷阱”
安装phpunit出现could not extract the package.xml file
Centos Nginx + Svbversion配置安装
双系统XP和ubuntu,升级ubuntu出现no such device grub rescue
centos5 源码安装Nginx + mysql + apache + php
再谈fgetcsv之在ubuntu10.10下不能解析中文的问题
原文地址:https://www.cnblogs.com/scottckt/p/1005116.html
最新文章
Openfire S2S 连接建立与消息发送
HotWheels
erlang debug 调试
JAVA Timer and task
JAVASwing GridBagLayout 布局
DelayQueue 队列
Openfire Could not locate home
erlang socket
Openfire MultiUserChat 多用户聊天 创建聊天室
MySQL Event
热门文章
MySQL 动态SQL
T_SQL 语句编程与高级查询
数据库的实现
存储过程
事务处理
数据库的设计
Coded UI Run Coded UI in WinForm
How to edit registry via CMD command
How to add AppBar
2013, I need change myself
Copyright © 2011-2022 走看看