asp:dropdownlist

  • Thread starter Thread starter Marius
  • Start date Start date
M

Marius

Hi all,

I need an asp:dropdownlist on a webform that is databound to a
dataset.
This works fine and returns the data to populate my dropdownlist.
In the DB I only have valid data, but I need a option like "< Select a
Region>"
to be displayd as teh selected value. Currently it displays the first
value of the returned dataset. I cannot seem to get this right, below
is my code:

<asp:dropdownlist DataTextField="City" DataValueField="Code"
DataSource="<%# dsReg.DefaultView %>" ID='region' CssClass='Print'
runat="server">
<asp:listitem selected="True" Value="">Select a
Region</asp:listitem>
</asp:dropdownlist>

The code above somehow completely ignores the asp:listitem tag.
Is this a serverside vs clientside issue? If so, please advise how the
desired effect could be accomplished.

Thanks

Marius
 
Add this line after calling dropdown.databind()
mydropdown.items.insert("Select a Region", 0)
 
Back
Top