How to validate the value selected in the dropdownlist

0

I'm using CompareValidator to check if the value selected in the dropdownlist is "Select", but not working, follow the code.

<asp:DropDownList ID="ddlIdPisSt" runat="server" DataSourceID="sdsIdPisSt" DataTextField="Descricao"  
    DataValueField="Id" AppendDataBoundItems="True" Width="790px">
    <asp:ListItem Value="">Selecione</asp:ListItem>
</asp:DropDownList>                 
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="ddlIdPisSt" Display="Dynamic" 
    ErrorMessage=" * " Operator="NotEqual" ValueToCompare="" ForeColor = "Red">
</asp:CompareValidator>

What I'm doing wrong. Can someone help me.

    
asked by anonymous 30.11.2015 / 16:55

1 answer

4

Friend, try to use the RequiredValidator, because the "Select" does not contain value and the RequiredValidator will catch.

Try and talk to us if it worked.

    
30.11.2015 / 17:29