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" />
asp:SqlDataSource>
|
|
|
|
|
Share this article
| Print |
Article read by 2943 times
|
|
|