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

  • Thread starter Thread starter Claudia Fong
  • Start date Start date
C

Claudia Fong

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
 
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
 
Back
Top