can't select one of the item in the drop down list

Discussion in 'ASP .Net' started by Claudia Fong, Nov 19, 2007.

  1. Claudia Fong

    Claudia Fong Guest

    HI,

    I have a drop down list that I manually bond the values:

    In my pageLoad I have this code


    connectionInfo =
    ConfigurationSettings.AppSettings["ConnectionString"];connection = new
    SqlConnection(connectionInfo);
    connection.Open();

    Command = connection.CreateCommand();

    Command.CommandText = "SELECT DISTINCT Destination.DestinationId,
    Destination.DestinationName" +
    " FROM Destination ";

    dataReader = Command.ExecuteReader();if (dataReader.HasRows)
    {

    drpDestination.DataSource = dataReader;

    drpDestination.DataTextField =
    "DestinationName";drpDestination.DataValueField = "DestinationId";
    drpDestination.DataBind();

    }

    dataReader.Close();

    }

    And then I will insert two more items in the drop down list:

    protected void drpDestination_DataBound(object sender, EventArgs e)
    {

    drpDestination.Items.Insert(0, new ListItem("Automatic",
    "0"));drpDestination.Items.Insert(1, new ListItem("Cancel Send", "1"));


    }

    So, my items in the ddl are: Automatic, Cancel Send, I30, K33, S30,
    etc..

    I'm able to select every item except the I30 which has index 2;
    everytime that I select I30, it will automatically switch to Cancel
    Send, index 1. I have no idea what is wrong or why it does this..

    Can someone help me?

    Cheers!

    Claudi

    *** Sent via Developersdex http://www.developersdex.com ***
    Claudia Fong, Nov 19, 2007
    #1
    1. Advertising

  2. Hi, Claudia,

    Did you check the generated HTML?

    Make sure that both items does not have the same value.

    I believe that the "I30" item has the value of "1", which is the value
    of your "Cancel Send" item.

    And that will make the browser select the first item matching the
    value.

    Regards,

    Paulo Santos
    http://pjondevelopment.50webs.com


    On Nov 19, 10:56 am, Claudia Fong <> wrote:
    > HI,
    >
    > I have a drop down list that I manually bond the values:
    >
    > In my pageLoad I have this code
    >
    > connectionInfo =
    > ConfigurationSettings.AppSettings["ConnectionString"];connection = new
    > SqlConnection(connectionInfo);
    > connection.Open();
    >
    > Command = connection.CreateCommand();
    >
    > Command.CommandText = "SELECT DISTINCT Destination.DestinationId,
    > Destination.DestinationName" +
    > " FROM Destination ";
    >
    > dataReader = Command.ExecuteReader();if (dataReader.HasRows)
    > {
    >
    > drpDestination.DataSource = dataReader;
    >
    > drpDestination.DataTextField =
    > "DestinationName";drpDestination.DataValueField = "DestinationId";
    > drpDestination.DataBind();
    >
    > }
    >
    > dataReader.Close();
    >
    > }
    >
    > And then I will insert two more items in the drop down list:
    >
    > protected void drpDestination_DataBound(object sender, EventArgs e)
    > {
    >
    > drpDestination.Items.Insert(0, new ListItem("Automatic",
    > "0"));drpDestination.Items.Insert(1, new ListItem("Cancel Send", "1"));
    >
    > }
    >
    > So, my items in the ddl are: Automatic, Cancel Send, I30, K33, S30,
    > etc..
    >
    > I'm able to select every item except the I30 which has index 2;
    > everytime that I select I30, it will automatically switch to Cancel
    > Send, index 1. I have no idea what is wrong or why it does this..
    >
    > Can someone help me?
    >
    > Cheers!
    >
    > Claudi
    >
    > *** Sent via Developersdexhttp://www.developersdex.com***
    PJ on Development, Nov 19, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SirPoonga
    Replies:
    2
    Views:
    742
    Ben Strackany
    Jan 7, 2005
  2. Ron
    Replies:
    3
    Views:
    458
    Anders Thorsen Holm
    Jul 19, 2003
  3. weiwei
    Replies:
    0
    Views:
    1,001
    weiwei
    Jan 5, 2007
  4. Replies:
    5
    Views:
    252
  5. Replies:
    3
    Views:
    275
Loading...

Share This Page