Xpode.com        Click here to Print this article.

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

Write the property of dropdownlist.


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" />


Contributed by:
Rohit kakria
I am software developer

Resourse address on xpode.com

Click here to go on website