473,320 Members | 2,161 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

DropDownList Program in ASP.Net

There are two dropDownLists on my form. In one DropDownList items
are-
1)BE
2)Drawing
3)PG

I want if a user selects BE in dropdownlist3 then in dropDownlist4 items are
IT, CSE, MECH


I want if a user selects Drawing in dropdownlist3 then in dropDownlist4 items are
Drawing1, Drawing2


I want if a user selects PG in dropdownlist3 then in dropDownlist4 items are
MBA, MSC, MCA

I do the foll. coding,but errors are there--
Check it out--

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DropDownList3.Items.Clear();
DropDownList3.Items.Add("BE");
DropDownList3.Items.Add("Drawing");
DropDownList3.Items.Add("PG");
}
protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList3.SelectedItem ="BE")
{
DropDownList4.Items.Clear();
DropDownList4.Items.Add("IT");
DropDownList4.Items.Add("CSE");
DropDownList4.Items.Add("MECH");
}
else if (DropDownList3.SelectedItem ="Drawing")
{
DropDownList4.Items.Clear();
DropDownList4.Items.Add("Drawing 1");
DropDownList4.Items.Add("Drawing 2");
}
else
{
DropDownList4.Items.Clear();
DropDownList4.Items.Add("MBA");
DropDownList4.Items.Add("MSC");
DropDownList4.Items.Add("MCA");

}
}
}

But Its not working.
May 14 '08 #1
3 1338
nateraaaa
663 Expert 512MB
What error are you getting back from your application?

Nathan
May 14 '08 #2
Error Operator '==' cannot be applied to operands of type 'System.Web.UI.WebControls.ListItem'
May 14 '08 #3
nateraaaa
663 Expert 512MB
Error Operator '==' cannot be applied to operands of type 'System.Web.UI.WebControls.ListItem'
Your conditional statements (if and else if) must compare using the == operator.

Expand|Select|Wrap|Line Numbers
  1.  if(dropdown1.SelectedValue == "BE") 
  2. {
  3. //do something
  4. }
  5.  
Nathan
May 15 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: theo | last post by:
Program flow...load file,then extract the xml text tags from the file,then the number of Xml tags retrieved from the file determines the number of dropdownlist controls instanciated in the...
6
by: Jason | last post by:
I have two drop down lists on my asp.net page, the second of which needs to be filled in based on the selection in the first dropdownlist. The catch however, is that it must occur without a...
1
by: | last post by:
This is a crosspost from a less-frequented (but more focused) asp.net group; I didn't receive an answer that worked. I'd like to get this form functional. Could someone help on what's probably a...
4
by: Luis Esteban Valencia | last post by:
Hi Everyone, How do you get two or more listitems to have the same value? I am trying to do this: <asp:dropdownlist id="one" runat="server"> <asp:listitem text="hello" value="hi" />
3
by: Olivier Verdin | last post by:
Hi, I have a page with several Textboxes and several DropDownList. When I click on a 'save' button, it creates a record in a database. The page works fine under Internet Explorer. It does...
1
by: oscar | last post by:
Hi expart, I have facing the problem of formatting the datetime in Dropdownlist. I am using Data Reader to retrive the date data from Sql2000 server and bind to DropDownList Control. The default...
1
by: Frank | last post by:
Hello, I have some text boxes and 2 drop down lists (DDL) within a panel like so: Everything updates fine but the values from the DDLs are always the items selected by default. In other words,...
1
by: Patrick Bates | last post by:
I've been holding off on moving to ASP.NET because I couldn't program the same way I did in VB6/ASP. Our existing apps are written using a 2- or 3-tier model, depending on how you look at it. The...
0
by: william.oram | last post by:
Assume a DataGrid that, during edit mode, has two DropDownMenus, ddlA and ddlB. Upon clicking 'Save,' the app performs the simplified task of copying the DDL values of each to a label. public...
2
by: spamguy | last post by:
Assume a DataGrid that, during edit mode, has two DropDownMenus, ddlA and ddlB. Upon clicking 'Save,' the app performs the simplified task of copying the DDL values of each to a label. public...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.