Reputation: 697
My page contains more than one dropdown list,in which some is mandatory fields,hence given required field validator.What i need is to include validation summarry,only if the datatable bound to DDL is empty,ie,only if the DDL contains no data to chose from.Ho to achieve this?
Upvotes: 1
Views: 89
Reputation: 7107
This is for your Knowledge:
<asp:panel ID="ErrorsPanel" runat="server" CssClass="ErrorSummary">
<asp:CustomValidator id="CustomValidator1" runat="server"
Display="None" EnableClientScript="False"></asp:CustomValidator>
<asp:ValidationSummary id="ErrorSummary" runat="server"
HeaderText="Errors occurred:"></asp:ValidationSummary>
</asp:panel>
Whenever you find the ddl is empty, you should execute this below code :
CustomValidator1.IsValid = False
CustomValidator1.ErrorMessage = "The DDL is Empty"
you can also use the Required field validator for the specific control.
Hope this helps...
Upvotes: 1