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();
——宽田 著——
查看全文
相关阅读:
实线矢量元素提取
matlab写txt文件
matlab之boundary()函数
matlab之flipud()函数
matlab unique()函数
KD-tree
matlab之细胞数组
matlab的代码注释
matlab中的try...catch...end
(转)MySQL 加锁处理分析
原文地址:https://www.cnblogs.com/scottckt/p/1005116.html
最新文章
Log4J日志配置具体解释
斜堆
Java程序猿的JavaScript学习笔记(9—— jQuery工具方法)
野鸟装备3.0问题汇总
Suffix Array 后缀数组
【Python】python网络协议
基于Hadoop2.5.0的集群搭建
unity3d Pathfinding插件使用
(素数求解)I
bond模式
热门文章
一分钟在云端快速创建MySQL数据库实例
Windows Azure系列公开课
“微软热爱Linux“ – 心声传遍中国
Gartner发布最新魔力象限报告,微软领跑数据库市场(编译自TechRepublic)
《IT老外在中国》第11期:首次访华的编程巨匠、C#之父Anders
Windows Azure系列公开课
微软技术大会,点亮“互联网+”创新机遇
Windows Azure系列公开课
为什么懂云的IT高手能过得比你好
构建微软智能云:介绍新的Azure业务转型创新技术
Copyright © 2011-2022 走看看