asp:dropdownlist

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
 
R

Rajesh.V

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

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

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top