locked
dropdownlist RRS feed

  • Question

  • when select a value from dropdownlist ,other dropdownlist should be disabled check my code

    protected void ddl_deptname_SelectedIndexChanged(object sender, EventArgs e)
        {

            if (ddl_deptname.SelectedIndex!= (Convert.ToInt32("ORR-ORR") && (Convert.ToInt32("ORR-TOWNSHIP"))))
                   { 
                ddl_orr.Enabled=false;
                ddl_township.Enabled=false;
                }
           if(ddl_deptname.Text=Convert.ToInt32("ORR-ORR"))
                    ddl_township.Enabled=false;
             else
                 ddl_orr.Enabled=false;
            
                  
        }

    so here,deptname values are orr-orr and orr-township.

    when user selects orr-orr,orr-orr dropdownlist should be disabled.

    error is coming.

    && operator cannot convert int to string

    just give an idea for that.

    thanks&regards

    madhu

     


    madhu
    Thursday, January 13, 2011 11:00 AM

Answers

  • Just Seperate the two conditions:

    if (ddl_deptname.SelectedIndex!= (Convert.ToInt32("ORR-ORR")) && ddl_deptname.SelectedIndex!=(Convert.ToInt32("ORR-TOWNSHIP")))

     

    Noam B.

     



    Do not Forget to Vote as Answer/Helpful, please. It encourages us to help you...
    • Proposed as answer by Noam B Saturday, January 15, 2011 8:58 PM
    • Marked as answer by Leo Liu - MSFT Thursday, January 20, 2011 1:53 AM
    Thursday, January 13, 2011 11:14 AM
  • Can you see this?

    -->  ddl_deptname.Text=Convert.ToInt32("ORR-ORR")

    First of all

    Convert.ToInt32("ORR-ORR") ==> Should give an FormatException. [i.e. Incorrect format of the input string].

    2nd thing...

    Compiler cannot implicitly convert your integer number by 'Convert.ToInt32' to a 'String'. 

     

     


    Santosh.
    • Proposed as answer by Leo Liu - MSFT Wednesday, January 19, 2011 2:59 AM
    • Marked as answer by Leo Liu - MSFT Thursday, January 20, 2011 1:53 AM
    Thursday, January 13, 2011 11:20 AM

All replies

  • Just Seperate the two conditions:

    if (ddl_deptname.SelectedIndex!= (Convert.ToInt32("ORR-ORR")) && ddl_deptname.SelectedIndex!=(Convert.ToInt32("ORR-TOWNSHIP")))

     

    Noam B.

     



    Do not Forget to Vote as Answer/Helpful, please. It encourages us to help you...
    • Proposed as answer by Noam B Saturday, January 15, 2011 8:58 PM
    • Marked as answer by Leo Liu - MSFT Thursday, January 20, 2011 1:53 AM
    Thursday, January 13, 2011 11:14 AM
  • Can you see this?

    -->  ddl_deptname.Text=Convert.ToInt32("ORR-ORR")

    First of all

    Convert.ToInt32("ORR-ORR") ==> Should give an FormatException. [i.e. Incorrect format of the input string].

    2nd thing...

    Compiler cannot implicitly convert your integer number by 'Convert.ToInt32' to a 'String'. 

     

     


    Santosh.
    • Proposed as answer by Leo Liu - MSFT Wednesday, January 19, 2011 2:59 AM
    • Marked as answer by Leo Liu - MSFT Thursday, January 20, 2011 1:53 AM
    Thursday, January 13, 2011 11:20 AM