Pijama® 0 Denunciar post Postado Agosto 25, 2008 Pessoal Não estou entendendo o que ta faltando pra puxar os dados neste dropdownlist, alguem ai me ajuda? Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs) MyQueryMethod() End Sub Function MyQueryMethod() As System.Data.IDataReader Dim connectionString As String = "server='(local)'; user id='sa'; password='12345'; database='joaobarro'" Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString) Dim queryString As String = "SELECT [tiponegocioanunciante].* FROM [tiponegocioanunciante]" Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand dbCommand.CommandText = queryString dbCommand.Connection = dbConnection dbConnection.Open Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection) Return dataReader End Function o html é esse <font face="tahoma" size="2">Tipo de Negócio: <br /> <asp:DropDownList id="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AppendDataBoundItems="True"></asp:DropDownList> </font></td> Compartilhar este post Link para o post Compartilhar em outros sites
quintelab 91 Denunciar post Postado Agosto 25, 2008 Movido Plataforma .NET http://forum.imasters.com.br/public/style_emoticons/default/seta.gif Plataforma .NET » Web Applications Este evento SelectedIndexChanged é acionado quando você seleciona algum item do seu DropDownList, pelo que eu entendi você quer carregar seu DropDownList para isto você deve fazer no Page_Load do seu formulário por exemplo, não no próprio evento de SelectedIndexChanged. E sua função esta errada, desta forma não irá alimentar um DropDownList, de uma olhada nesta: Public Sub drop_dinamico(ByVal drop_name As DropDownList, ByVal vSql As String, ByVal descricao As String, ByVal id As Object) VerificaConexao(1) 'Abre a Conexão Dim sqlDrop As String = vSql Dim cmd_drop As New OleDbCommand(sqlDrop, Conexao) drop_name.DataValueField = id drop_name.DataTextField = descricao drop_name.DataSource = cmd_drop.ExecuteReader(CommandBehavior.CloseConnection) drop_name.DataBind() drop_name.Items.Insert(0, "- - Selecione - -") cmd_drop.Dispose() VerificaConexao(2) ' Fecha a conexão End Sub Obs.: Quando o tópico for referente web poste direto no Sub-Fórum de Web Applications. Abraços... Compartilhar este post Link para o post Compartilhar em outros sites