惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
IT之家
IT之家
Hugging Face - Blog
Hugging Face - Blog
J
Java Code Geeks
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 叶小钗
MyScale Blog
MyScale Blog
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
大猫的无限游戏
大猫的无限游戏
博客园 - 三生石上(FineUI控件)
Google DeepMind News
Google DeepMind News
Engineering at Meta
Engineering at Meta
The Cloudflare Blog
Martin Fowler
Martin Fowler
酷 壳 – CoolShell
酷 壳 – CoolShell
N
Netflix TechBlog - Medium
MongoDB | Blog
MongoDB | Blog
I
InfoQ
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
H
Help Net Security

博客园 - 木人(我现在不是老大)

ERP系统的专业化发展趋势 讨厌的real和float数据 Svcutil使用点滴 windows server2003企业版64位安装sql server2008企业版64位 读书笔记 UltraGrid(16) 水晶报表使用push模式(2) 水晶报表使用push模式(1) SQL SERVER2000存储过程调试 读书笔记 UltraGrid(15) 读书笔记 UltraGrid(14) 读书笔记 UltraGrid(12) 读书笔记 UltraGrid(11) 读书笔记 UltraGrid(9) 读书笔记 UltraGrid(8) 读书笔记 UltraGrid(7) 读书笔记 UltraGrid(6) 读书笔记 UltraGrid(5) 读书笔记 UltraGrid(4) 读书笔记 UltraGrid(3)
读书笔记 UltraGrid(10)
木人(我现在不是老大) · 2012-02-12 · via 博客园 - 木人(我现在不是老大)

关于绑定dataset

1.如果DataSet中建立了关系,则ultragrid中自动以dataset中的关系展示层次性的数据。
SqlDataAdapter da = new SqlDataAdapter("select * from customers;select * from pdctorders;select * from SaleContracts;", cnnstring);
da.TableMappings.Add("Table", "客户");
da.TableMappings.Add("Table1", "订单");
da.TableMappings.Add("Table2", "合同");
da.Fill(data);

DataRelation mydr = new DataRelation("Customers_PdctOrders", data.Tables["客户"].Columns["CustID"], data.Tables["订单"].Columns["CustID"], false);
data.Relations.Add(mydr);
DataRelation mydr2 = new DataRelation("Customers_SaleContracts", data.Tables["客户"].Columns["CustID"], data.Tables["合同"].Columns["CustID"], false);
data.Relations.Add(mydr2);
我们查看ultraGrid1.DisplayLayout.Bands,发现共有3个UltraGridBand,key分别是“客户”、“Customers_PdctOrders”和"Customers_SaleContracts";
也就是ultraGrid1.DisplayLayout.Bands包含所有的band。
关于key,除最顶层外,其余的名字都取自DataRelation的名字;
为什么要有一个Bands体现所有的band呢?似乎为了访问的方便性?
顶层的band,即ultraGrid1.DisplayLayout.Bands[0]只能有一个且必须有一个!
2.ultraGrid1.DisplayLayout.Bands中band之间的关系通过ParentBand来体现。
如果是顶层band则ParentBand为空;
从关系上来看,band是没有childband的,childband是属于ultrarow的,并且一个ultrarow可以由几个childband;
3.总是觉得SqlDataAdapter da = new SqlDataAdapter("select * from customers;select * from pdctorders;select * from SaleContracts;", cnnstring);这样执行不是将三个表中所有的数据都给检索出来了?
是否可以只在行展开的时候再检索数据呢?
当然这样做childband上的数据是不全的。排序等方面应该禁止吧。
可以在 ultraGrid1中BeforeRowExpanded事件中写入如下代码:
string custID=e.Row.Cells["CustID"].Value .ToString ();
//考虑多次展开不能有重复数据,每次都从数据库中检索
DataRow[] drs= data.Tables ["订单"].Select("CustID='"+custID+"'");

for(int i=drs.GetLength(0)-1;i>=0;i--)
   drs[i].Delete();
           
da = new SqlDataAdapter("select * from pdctorders where custid='" + custID + "'", cnnstring);
da.Fill(data, "订单");

drs = data.Tables["合同"].Select("CustID='" + custID + "'");
for (int i = drs.GetLength(0) - 1; i >= 0; i--)
   drs[i].Delete();
data.AcceptChanges();

da = new SqlDataAdapter("select * from SaleContracts where custid='" + custID + "'", cnnstring);
da.Fill(data, "合同");
可以进一步考虑:
是否每次都要从数据库中检索呢?
个人觉得可以使用row的tag标记记录是否第一次展开。否则就不再从数据库中检索。
当然也要提供一种机制,可强制从数据库中再次检索。