Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




How to add select word at 0 index while using sqldatasource and Dropdownliast

Write the property of dropdownlist.

AppendDataBoundItems="true"

Now write next line

< asp:ListItem Selected="true" Text="Select one" Value="-1" />

Full code is

< asp:DropDownList ID="DropDownList1" EnableCaching="false" runat="server" DataSourceID="CompSource" DataTextField="CName" DataValueField="ID" Width="300px" AutoPostBack="true" AppendDataBoundItems="true">
< asp:ListItem Selected="true" Text="Select one" Value="-1" />

< asp:SqlDataSource ID="CompSource" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnection %>" SelectCommand="SPSelect" SelectCommandType="StoredProcedure">
< SelectParameters>
< asp:Parameter DefaultValue="false" Name="Del" Type="Boolean" />
< asp:Parameter DefaultValue="True" Name="Show" Type="Boolean" />

Share this article   |    Print    |    Article read by 2943 times
Author:
Rohit kakria
I am software developer
Related Articles: No related article
Related Interview Questions: No related interview question