-- 作者:菜鸟foxtable
-- 发布时间:2009/2/1 16:39:00
-- DataList控件CurrentChanged事件BUG?(已解决)
如题,如果当前DataList只有一行,CurrentChanged事件无法执行.
在CurrentChanged事件里加入如下代码: Dim cmd As New SQLCommand cmd.Con nection Name = "zygl" 此行ConnectionName论坛显示不正常,所以故意留空格 Dim dst1 As WinForm.DataList = e.Form.Controls("DataList1") Dim dst2 As WinForm.DataList = e.Form.Controls("DataList2") if dst1.count>0 then Dim dr1 as DataRow = dst1.Current dim str as string = dr1("住院ID") cmd.CommandText = "SELECT * FROM [长嘱] where 住院ID = \'"& str &"\'" dst2.DataTable = cmd.ExecuteReader() dst2.Build() end if
如果DataList1只有一行,BUG出现,选择此行,代码执行不正确.DataList2输出值为空.
此主题相关图片如下:001.jpg
点击任意一列排序,DataList2才正常输出.
此主题相关图片如下:002.jpg
[此贴子已经被作者于2009-2-1 17:11:51编辑过]
|
-- 作者:菜鸟foxtable
-- 发布时间:2009/2/1 17:05:00
--
以下是引用ybil在2009-2-1 17:02:00的发言: 何來Bug!Current沒有改變,當然不會執行.
明白了,加载窗口时执行下列代码可以解决问题: Dim cmd As New SQLcommand cmd.Con nection Name = "zygl" cmd.CommandText = "Select 住院ID,入院日期,床位,住院号,姓名,性别,年龄,入院诊断,出院申请 From [住院登记] where 出院结账 = False" Dim dst As WinForm.DataList = e.Form.Controls("DataList1") dst.DataTable = cmd.ExecuteReader() dst.Build() Dim dst2 As WinForm.DataList = e.Form.Controls("DataList2") if dst.count = 1 then Dim dr1 as DataRow = dst.Current dim str as string = dr1("住院ID") cmd.CommandText = "SELECT * FROM [长嘱] where 住院ID = \'"& str &"\'" dst2.DataTable = cmd.ExecuteReader() dst2.Build() end if
[此贴子已经被作者于2009-2-1 17:16:23编辑过]
|