Skip to content

Drop Down List Entries

Mic keeey

Asked Dec 12, 2007, 11:00 PM EST1 answer
Share
LinkedInX
Hi,

I have used several drop down list boxes for my program.
So far I have managed to get the information from SQLServer. However, I have noticed that I keep getting one or two blank cells within my drop down lists.
Really I would like to get rid of these blank cells in order to make the drop down lists look neat.

Does anyone know why this is happening and whether there is a solution to this problem?

Thanking you in advance

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Do you have the code that loads the drop doqn box? If you just want to get rid of these blanks, you could always iterate through the items in the drop down list:

    int i = 0;

    foreach (Item item in dropDownList.Items)
    {
        if(item.Text == String.Empty)
        {
           dropDownList.Items.RemoveAt(i);
        }
        i++;
    }
    0