Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear, All
I use SqlDatasoure for showing item on dropdownlist. So, My question is "How to show the title like "Select Level" before the item list i have query from SqlDatasource?"

Appreciated for your kindly help again
Posted
Updated 9-Sep-12 7:32am
v2

Hi ,
Check this
ASP.NET
    <div>
    <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True"
    ValidationGroup="ss" DataSourceID="SqlDataSource1" DataTextField="name" 
            DataValueField="productID">
<asp:ListItem Text="---select---" Value="0" ></asp:ListItem>
 
 
</asp:DropDownList>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:testConnectionString %>" 
            SelectCommand="SELECT [productID], [name] FROM [Product]">
        </asp:SqlDataSource>
    </div>

Best Regards
M.Mitwalli
 
Share this answer
 
v2
Comments
Cmajorros 9-Sep-12 13:59pm    
Thanks you so much.
Mohamed Mitwalli 9-Sep-12 14:00pm    
Your welcome if it help you accept the answer
__TR__ 10-Sep-12 4:12am    
+5
Mohamed Mitwalli 10-Sep-12 4:14am    
Thanks TR :)
Cmajorros 13-Feb-13 11:40am    
Anyway I have solve my problems already. I just created new page and copy sever side code. It 's work. Although it seems to be a stupid solution,at least It works well. Thank you all guys for your kindly help
For such title, use the control System.Web.UI.WebControls.Label:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.label.aspx[^].

—SA
 
Share this answer
 
Hello !
I think you can add the DropDownList item manualy before you connect the SqlDatasource (something is here).

Josef Pospisil
 
Share this answer
 
Anyway I have solve my problems already. I just created new page and copy sever side code. It 's work. Although it seems to be a stupid solution,at least It works well. Thank you all guys for your kindly help
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900