![]() | CYQ.Data componentsCYQ.Data support multi-database application [Txt,Xml,Access, MSSQL, Oracle,SQLite,MySql], help easily and quickly to develop your project |
CYQ.Data 数据框架 使用篇三 MAction 取值与赋值
Guide |
|
|
| #TopicOwner |
本节内容: 本篇继续上一篇内容,本节介绍所有取值与赋值的相关操作。
1:UI操作:GetFrom与SetTo 2:非UI操作:Get与Set 3:DrowDownList等列表控件的UI操作
代码共同部分提前说明,我们假设以通过以下方法查询完一行数据 using(MAction action = new MAction(TableNames.Users))
{
if (action.Fill(888)) { //这里是本节要说的取值与赋值操作 } } 一: UI操作(通常都采用自动化批量操作,不会一个一个操作) 说明:控件ID遵守起名约定:任意三个字母前缀+字段名称 例如TextBox控件ID为:txtUserName 则为txt(任意前缀)+UserName(数据库字段名称) 1:GetFrom 从控件中取值设置到行中 方法原型: public void GetFrom(Control ct) public void GetFrom(Control ct, object value) 示例1: action.UI.GetFrom(txtUserName);//从控件中取值并赋值到数据行中 //等同于 action.Data["UserName"].Value=txtUserName.Text; 示例2: action.UI.GetFrom(txtUserName, "路过秋天");//将自定义值赋给数据行,忽略控件的值。 //等同于 action.Data["UserName"].Value="路过秋天"; 2:SetTo 将数据行中的数据设置到控件 方法原形: public void SetTo(Control ct) public void SetTo(Control ct, object value) public void SetTo(Control ct, object value, bool isControlEnabled) 示例1: action.UI.SetTo(txtUserName);//给控件赋值,数据来源于数据行。 //等同于: txtUserName.Text=action.Data["UserName"].Value.ToString(); 示例2: action.UI.SetTo(txtUserName,"路过秋天");//给控件赋值,数据来源于自定义值 //等同于 txtUserName.Text="路过秋天"; 示例3: action.UI.SetTo(txtUserName,null,false);//给控件赋值,同时设置控件Enable属性 //等同于: txtUserName.Text=action.Data["UserName"].Value.ToString(); txtUserName.Enabled=false; 二:非UI操作 1:Get 从行中获取数据 原生方法:public T Get<T>(object key) 示例1: string userName = action.Get<string>(Users.UserName);//从数据行中取值 //等同于 string userName = action.Data["UserName"].Value.ToString(); 2:Set 从变量中设置值到行中 原生方法:public void Set(object key,object value) 示例1: action.Set(Users.UserName, "路过秋天");//给字段UserName赋值 //等同于: action.Data["UserName"].Value = "路过秋天"; 三:UI操作:DrowDownList等列表控件的UI操作 方法原型:
public MAction Bind((object control) public MAction Bind(string control, string where)
public MAction Bind((object control, string where, object text, object value) 示例1: using(MAction action = new MAction(TableNames.Users))
{
action.UI.Bind(ddlUserName);//查询数据并绑定下拉列表,文本域为UserName[去掉三个任意前缀],值域为ID } 示例2: using(MAction action = new MAction(TableNames.Users))
{
action.UI.Bind(ddlUserName,"id>10");//按条件查询数据并绑定下拉列表,文本域为UserName,值域为ID } 示例3: using(MAction action = new MAction(TableNames.Users))
{
action.UI.Bind(ddlUserName,"id>10",Users.NickName,Users.ID);//按条件查询数据并绑定下拉列表,文本域为NickName,值域为ID } ![]() |
Aspen[147.99.111.*]2011/6/24 3:26:32 | #2 | |
![]() | Great hmamer of Thor, that is powerfully helpful! |
Post Comment
Bulletin
Article Search
Categories
- Platform for dynamic (20)
- Feedback (9)
- Guide (33)
- Principles (19)
- Project-Case (8)
- Business & Buy (2)
- Technology exchange (45)
New Article
- CYQ.Data Components Getting Started Guide [Part 5]-[MProc Execute Stored Procedures or SQL]
- CYQ.Data Components Getting Started Guide [Part 4]-[MAction Insert Delete Update]
- CYQ.Data Components Getting Started Guide [Part 3]-[MAction Get And Set Value]
- CYQ.Data Components Getting Started Guide [Part 2]-[MAction Data Query- Fill And Select]
- CYQ.Data Components Getting Started Guide [Part 1]
New Comment
- When some one searches for his necessary thing, therefore he/she wishes to be available that in detail, so that thing is maintained over here.
- This is my first time pay a quick visit at here and i am in fact happy to read everthing at alone place.
- I truly appreciate this blog article.Really thank you! Cool.
- please pay a visit to the web sites we follow, like this one particular, as it represents our picks in the web
- Really enjoyed this post.Really thank you!
- Really enjoyed this article.Really looking forward to read more. Great.
- poker bonuses What are the norms of copyright of web content? How as it different from Patent?
- Wow! Thank you! I permanently needed to write on my blog something like that. Can I implement a fragment of your post to my site?
- This website was how do I say it? Relevant!! Finally I ave found something that helped me. Cheers!
- I was reading through some of your content on this internet site and I believe this web site is very informative ! Continue posting.