-3

We have a Modal Popup that includes a DropDownList, which looks like this:

<asp:DropDownList ID="DropDownListSalesmen" runat="server" 
    DataSourceID="SqlDataSourceSales" DataTextField="FullName" 
    DataValueField="Member_Code" ></asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSourceSales" runat="server" 
    ConnectionString="<%$ ConnectionStrings:SalesConnectionString %>" 
    SelectCommand="usp_NsbGetSalesmen" SelectCommandType="StoredProcedure">
</asp:SqlDataSource>

The stored procedure that populates this

FullName         Member_Code
Select user      0
Joe              1
Jim              2
Mary             3

The modal popup also includes an OK button that's clicked once a user is selected from the list.

I would like to add a validator here, so if the user clicks on "OK" when Member_Code equals 0 (item Select user) then display a warning message saying that a valid selection has to be made.

What kind of validator should I add here? I prefer doing this validation client-side with the asp.net Validation controls.

Thanks.

EDIT: I had tried the link suggested as a duplicate, but the issue was that it would be in a modal popup. For some reason, the solution in the link was not working.

fdkgfosfskjdlsjdlkfsf
  • 3,165
  • 2
  • 43
  • 110

1 Answers1

0

I found a solution here.

<asp:RequiredFieldValidator ID="rfv1" runat="server" ControlToValidate="DropDownListSalesmen" InitialValue="0" ErrorMessage="Please select valid salesman" />
fdkgfosfskjdlsjdlkfsf
  • 3,165
  • 2
  • 43
  • 110