这个功能怎么实现?
strSQL = "SELECT * FROM Lib "
SQLCon.SelectSQL(strSQL, DBset, "TempTable ") '打开数据库,填充到TempTable
'遍历Form1种的所有控件, 从中找出所有的DropDownList控件
For Each ctrl As Control In Me.Form.Controls
If ctrl.GetType.ToString = "System.Web.UI.WebControls.DropDownList " Then
For Each dr As DataRow In DBset.Tables( "TempTable ").Select( "Awhere = ' " & ctrl.ID & " ' ")
'问题在这
'这里面根据查询条件填充DropDownList
'我想ctrl.ID .Items.Add(dr( "Aname ").ToString)这么填充,可是不行
Next
End If
Next
下面是这个表(Lib)的数据库脚本
if exists (select * from dbo.sysobjects where id = object_id(N '[dbo].[Lib] ') and OBJECTPROPERTY(id, N 'IsUserTable ') = 1)
drop table [dbo].[Lib]
GO
CREATE TABLE [dbo].[Lib] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[Aname] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[Awhere] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[Avalue] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO
[解决办法]
For Each ctrl As Control In Me.Form1.Controls
↑ 这里有个1吧,既然是Form1中的控件