1
Answer

display validation error for dropdownlist linked with DB

Joma Alrzini

Joma Alrzini

8y
303
1
This the code I tried but the validation message not appeared  
 
<asp:DropDownList ID="DropDownList2" runat="server" EnableViewState="true" DataSourceID="SqlDataSource6" DataTextField="MName" DataValueField="MId" Width="130px" Height="25px"><asp:ListItem>Select ModuleID</asp:ListItem>
</asp:DropDownList>
<span runat="server" style="color:red; font-size:20px">*</span>
<asp:RequiredFieldValidator ErrorMessage="Module ID is a required field." id="RequiredFieldValidator3" ForeColor="Red" ControlToValidate="DropDownList2"
runat="server" ValidationGroup="click" />
<asp:SqlDataSource ID="SqlDataSource6" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [MId], [MName] FROM [Modules]"></asp:SqlDataSource>
Answers (1)