日期:2014-05-18  浏览次数:20394 次

为什么这样增加DropDownList值没效果
我想自己设定下拉列表中的选项,可是列表始终是空白地,哪里问题?

sub   show_fenlei
Dim   connstr   As   String   =   ConfigurationSettings.AppSettings( "ConnectionString ")
Dim   queryString   As   String   =   "select   id,mingcheng   from   lanmu   where   fulei   =   0   order   by   paixu "
Using   connection   As   New   OdbcConnection(connstr)
Dim   command   As   New   OdbcCommand(queryString,   connection)
connection.Open()
Dim   reader   As   OdbcDataReader   =   command.ExecuteReader()
While   reader.Read()
fenlei.Items.Insert(0,   new   ListItem(reader.getString(0),   reader.getString(1)))
End   While
reader.Close()
End   Using
end   sub

....
<asp:DropDownList   ID= "fenlei "   runat= "server "> </asp:DropDownList>  
<%call   show_fenlei%>


------解决方案--------------------
1.有没有查询到数据? 2.还是查询到了数据reader.getString(0)为空?
------解决方案--------------------
用dr[ "ColumnName "]