当前位置: 代码迷 >> ASP.NET >> 为啥这样增加DropDownList值没效果
  详细解决方案

为啥这样增加DropDownList值没效果

热度:7635   发布时间:2013-02-25 00:00:00.0
为什么这样增加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 "]
  相关解决方案