G
Guest
Hi all,
I’ve got a ‘dropdownlist’ web control and I can add ‘listitem’ no problem. I
can also bind data from an SQL database fine. My problem is that I want to
do both at the same time to allow me to have the first option in the list a
‘listitem’ saying something like ‘please pick an option’, and then the rest
of options coming from the database.
<asp:dropdownlist id="fm_Category" runat="server" DataTextField="CatName"
DataValueField="CatID">
<asp:ListItem Selected="true">please pick an option</asp:ListItem>
</asp:dropdownlist>
The options from the database seem to take priority and the ‘listitem’ is
not shown at all. Doing this in classic asp was easy as you could obviously
just write two ‘options’ and then loop the second one with data from the
database.
This is what I’m looking for:
<select name="fm_Category" id="fm_Category">
<option value="">please pick an option</option>
<option value="1">Data from db 1</option>
<option value="2">Data from db 2</option>
<option value="3">Data from db 3</option>
</select>
I’ve only just started to learn asp.NET having come from classic asp so I
hope I’m not just being stupid with this. Any help would be great?
Thanks
Steve
I’ve got a ‘dropdownlist’ web control and I can add ‘listitem’ no problem. I
can also bind data from an SQL database fine. My problem is that I want to
do both at the same time to allow me to have the first option in the list a
‘listitem’ saying something like ‘please pick an option’, and then the rest
of options coming from the database.
<asp:dropdownlist id="fm_Category" runat="server" DataTextField="CatName"
DataValueField="CatID">
<asp:ListItem Selected="true">please pick an option</asp:ListItem>
</asp:dropdownlist>
The options from the database seem to take priority and the ‘listitem’ is
not shown at all. Doing this in classic asp was easy as you could obviously
just write two ‘options’ and then loop the second one with data from the
database.
This is what I’m looking for:
<select name="fm_Category" id="fm_Category">
<option value="">please pick an option</option>
<option value="1">Data from db 1</option>
<option value="2">Data from db 2</option>
<option value="3">Data from db 3</option>
</select>
I’ve only just started to learn asp.NET having come from classic asp so I
hope I’m not just being stupid with this. Any help would be great?
Thanks
Steve