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

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
V2EX
大猫的无限游戏
大猫的无限游戏
腾讯CDC
博客园 - Franky
WordPress大学
WordPress大学
Jina AI
Jina AI
GbyAI
GbyAI
云风的 BLOG
云风的 BLOG
B
Blog RSS Feed
Last Week in AI
Last Week in AI
The Cloudflare Blog
V
Visual Studio Blog
P
Proofpoint News Feed
博客园 - 叶小钗
L
LangChain Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Recorded Future
Recorded Future
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
Y
Y Combinator Blog
罗磊的独立博客
雷峰网
雷峰网
博客园 - 【当耐特】
Microsoft Security Blog
Microsoft Security Blog
L
LINUX DO - 热门话题
Cisco Talos Blog
Cisco Talos Blog
L
Lohrmann on Cybersecurity
Martin Fowler
Martin Fowler
Spread Privacy
Spread Privacy
MongoDB | Blog
MongoDB | Blog
Engineering at Meta
Engineering at Meta
C
Cybersecurity and Infrastructure Security Agency CISA
小众软件
小众软件
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Recent Announcements
Recent Announcements
T
Threat Research - Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
量子位
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
宝玉的分享
宝玉的分享
D
DataBreaches.Net
T
The Exploit Database - CXSecurity.com
Vercel News
Vercel News
IT之家
IT之家
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
Troy Hunt's Blog
aimingoo的专栏
aimingoo的专栏

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

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标记记录是否第一次展开。否则就不再从数据库中检索。
当然也要提供一种机制,可强制从数据库中再次检索。