![]() | CYQ.Data componentsCYQ.Data support multi-database application [Txt,Xml,Access, MSSQL, Oracle,SQLite,MySql], help easily and quickly to develop your project |
MDataTable 原理解析 数据控件绑定-上篇
Principles |
|
|
| #TopicOwner | ||||||||
继上一节实现MDataTable之后,我们再为MDataTable加上一个NewRow()方法,以便能构造出该表的新行 如下: ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
OK,接下来,我们新建一个Demo的web工程,在Default.aspx中随便拖一个GridView控件进去,然后在Page_Load里写下以下代码: ![]() ![]() MDataTable table=new MDataTable("myTableName"); table.Columns.Add("A", SqlDbType.NVarChar); table.Columns.Add("B",SqlDbType.NVarChar); MDataRow mdr = table.NewRow(); mdr[0].Value = "helloA"; mdr[1].Value = "111111"; table.Rows.Add(mdr); GridView1.DataSource = table; GridView1.DataBind(); 敲mdr["A"]本来是要这样敲的,不支持字符串索,只好敲了mdr[0]了,这里顺路为MDataRow加上一个字符串索引,如下: ![]() ![]() public MDataCell this[string Key] { get { MDataCell dataCell = null; for (int i = 0; i < base.Count; i++) { if (base[i].ColumnName == Key) { dataCell = base[i]; break; } } return dataCell; } } OK,就这样添加了两个列头,又添加了一行数据,运行后看结果如下:
晕,数据根本不是我们想要的.... 上面显示的列,有三个都是Table的属性,还有一个ConnectionString是Table的行的属性 吓,咋就混在一块了。。。。 于是,我们开始动手寻找绑定之法...下一篇详解...... ![]() |
xiaoqunqttc2011/4/9 6:29:54 | #2 | |
![]() | 应该是table.Rows.Add(mdr),我找到了。cyq.data我要好好研究啊 reply: 呵呵,欢迎研究与使用。 |
xiaoqunqttc2011/4/9 6:24:11 | #1 | |
![]() | table.Add(mdr); 提示出错,没有add方法啊 |
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.