jafm Posted February 11, 2014 at 12:34 PM Report #544825 Posted February 11, 2014 at 12:34 PM Olá, Tenho informação numa DropDownlist, e gostaria que ao selecionar um dado item me colocasse uma label invisivel por exemplo, para isso usei o seguinte evento do click, mas algo me deve estar a faltar, alguem me consegue ajudar? Protected Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DropDownList1.SelectedIndexChanged If DropDownList1.SelectedItem.Text = "Teste" Then Label2.Visible = False End If End Sub Terei que usar outro evento?
nelsonr Posted February 11, 2014 at 12:50 PM Report #544832 Posted February 11, 2014 at 12:50 PM Deve faltar a propriedade Autopostback = true na dropdown
jafm Posted February 11, 2014 at 01:39 PM Author Report #544835 Posted February 11, 2014 at 01:39 PM Obrigado, era mesmo isso que estava a faltar.
jafm Posted February 11, 2014 at 05:00 PM Author Report #544864 Posted February 11, 2014 at 05:00 PM Mais só uma coisa, sobre a dropdownlist. Ele coloca por defeito logo uma variavel, mas eu queria ser eu a escolher a variavel, até lá encontra-se vazia.
jafm Posted February 11, 2014 at 05:15 PM Author Report #544868 Posted February 11, 2014 at 05:15 PM Tentei já colocar dllTeste.SelectedIndex = -1 mas vai me buscar sempre o primeiro item da lista.
nelsonr Posted February 11, 2014 at 05:46 PM Report #544882 Posted February 11, 2014 at 05:46 PM Julgo que a dropdownlist não permite estar sem items selecionados. O que podes fazer é inserir um elemento a vazio antes dos outros
jafm Posted February 12, 2014 at 10:43 AM Author Report #544992 Posted February 12, 2014 at 10:43 AM Ok, com essa alternativa não estou a conseguir trazer pra cima, fica sempre na ultima posição, o codigo que estou a usar é: 'dllTeste.Items.Add("") dllTeste.Items.Add(New ListItem("Select", "0", True)) dllTeste.SelectedIndex = "0"
nelsonr Posted February 12, 2014 at 10:49 AM Report #544993 Posted February 12, 2014 at 10:49 AM Podes usar o dllTeste.Items.Insert
jafm Posted February 12, 2014 at 11:34 AM Author Report #545002 Posted February 12, 2014 at 11:34 AM Boas, Resultou da seguinte forma dllTeste.Items.Insert(0, New ListItem("teste", "teste")) Obrigado pela Dica..
jafm Posted February 14, 2014 at 12:09 PM Author Report #545254 Posted February 14, 2014 at 12:09 PM (edited) Peço desculpa mas vou ter que reabrir o tópico.Pois tenho uma outra dúvida sobre as dropdownlist.Eu anteriormente estava a ir buscar informação à BD. Mas agora queria de um parametro O código que estou a usar é: If Not Page.IsPostBack Then Dim strSQL As String Dim Conn As OleDbConnection Dim daDrop As OleDbDataAdapter Dim dsDrop As DataSet strSQL = "select '" + Label4.Text + "' from Categoria" 'Abre a conexão com a fonte de dados Conn = New OleDbConnection(strConn) Conn.Open() Try 'cria o objeto DataAdapter daDrop = New OleDbDataAdapter(strSQL, Conn) 'Cria e preenche o DataSet dsDrop = New DataSet() daDrop.Fill(dsDrop, "Categoria") 'Define o preenchimento do controle DropDownList dllSiteDe.DataTextField = "'" + Label4.Text + "'" dllSiteDe.DataValueField = "'" + Label4.Text + "'" dllSiteDe.DataSource = dsDrop.Tables("Categoria").DefaultView dllSiteDe.DataBind() dllSiteDe.Items.Insert(0, New ListItem("", "")) Finally Conn.Close() End Try End If O erro que está a dar é no DataBind DataBinding: 'System.Data.DataRowView' não contém uma propriedade com o nome ''L''. Edited February 14, 2014 at 12:13 PM by jafm
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now