Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
I have two dropdownlist in one page.if i have clicked on one value from dropdownlist1.& i want to do dropdownlist2 is invisible..plz gv me solution
Posted
Updated 24-May-12 21:18pm
v3

try like this

SQL
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
       If DropDownList1.SelectedItem.Text = "Hi" Then
           DropDownList2.Visible = False
       End If
   End Sub
 
Share this answer
 
Comments
Member 9027346 25-May-12 3:40am    
I have tried but still there is error:can not implicitly convert type "string to bool"plz help me...
YOu can use Javascript

in aspx

ASP.NET
<asp:dropdownlist onchange="onchange()" id="Dropdownlist1" runat="server" xmlns:asp="#unknown">
                    </asp:dropdownlist>
<asp:dropdownlist id="Dropdownlist2" runat="server" xmlns:asp="#unknown">
                    </asp:dropdownlist>


this js should write down after your above html

JavaScript
function onchange()
{
    var dl1=document.getElementById("Dropdownlist1");
    var dl2=document.getElementById("Dropdownlist2");

    //  For Text
    if(dl1.options[dl1.selectedIndex].text=="your text")
        dl2.style.display="none";

    //  For Value
    if(dl1.value=="your value")
        dl2.style.display="none";


}
 
Share this answer
 
Add ddl2.Visible = false; on  DropDownList1_SelectedIndexChanged1
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900