learningnet
asked on
how to set the default value in the dropdownlist control
I am trying to show the list of names in the dynamic drop down listbox, using the following code.
<asp:DropDownList ID="lstLearnItName" runat="server" DataSourceID="dsLearnItNam es"
DataTextField="LearnItName " DataValueField="LearnItID" >
<asp:RequiredFieldValidato r ID="RequiredFieldValidator 1" runat="server"
ErrorMessage="enter a Product ID" ControlToValidate="lstLear nItName"
SetFocusOnError="True" Display="Dynamic"></asp:Re quiredFiel dValidator >
<asp:SqlDataSource ID="dsLearnItNames" runat="server" ConnectionString="<%$ ConnectionStrings:sConnect ionString %>"
SelectCommand="SELECT * FROM [LearnItName]"></asp:SqlDa taSource>
I just wanted to know how I can add a static listitem and set it to the default.
for an instance: <asp:ListItem Selected="true" Text="Please select" Value=""></asp:ListItem>
So that I can force the user to select an item before navigating to the next.
thanks in advance
regards
kay
<asp:DropDownList ID="lstLearnItName" runat="server" DataSourceID="dsLearnItNam
DataTextField="LearnItName
<asp:RequiredFieldValidato
ErrorMessage="enter a Product ID" ControlToValidate="lstLear
SetFocusOnError="True" Display="Dynamic"></asp:Re
<asp:SqlDataSource ID="dsLearnItNames" runat="server" ConnectionString="<%$ ConnectionStrings:sConnect
SelectCommand="SELECT * FROM [LearnItName]"></asp:SqlDa
I just wanted to know how I can add a static listitem and set it to the default.
for an instance: <asp:ListItem Selected="true" Text="Please select" Value=""></asp:ListItem>
So that I can force the user to select an item before navigating to the next.
thanks in advance
regards
kay
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
its still not forcing me to select some other item from the drop down listbox
<asp:RequiredFieldValidato
ErrorMessage="please choose the name" ControlToValidate="lstLear
SetFocusOnError="True" Display="Dynamic" InitialValue="Please Select"></asp:RequiredFiel
please can you still advise
thanks