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

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
 
P

PJ on Development

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,835
Latest member
lila30

Latest Threads

Top