r3try
r3try

Reputation: 677

Input parameter 'controlId' cannot be an empty string when using validator inside formview

I have got a FormView where I have several fields. Those fields should be validated by asp.net validators, like this:

<asp:FormView ID="OrderDetails" runat="server" DataKeyNames="ID" DataSourceID="DS_Order" DefaultMode="Edit" AutoGenerateRows="false" ClientIDMode="Static" RenderOuterTable="false">
    <EditItemTemplate>
        <asp:TextBox ID="EinkaufsauftragsNr" runat="server" ClientIDMode="Static" Text='<%# Bind("EinkaufsauftragsNr") %>'/>
        <asp:CompareValidator runat="server" Operator="DataTypeCheck" Type="Integer" ValidationGroup="EditValidation" Display="Dynamic"
                                    ControlToValidate="EinkaufsauftragsNr" ErrorMessage="Nur Ganzzahlen erlaubt." CssClass="validator" />
        .....
    </EditItemTemplate>
</FormView>

But when I execute this, I get: "Input parameter 'controlId' cannot be an empty string." When I remove the validator, the error-msg disappears as well.

After searching for this problem on the net, I thought the problem was that the control cannot be found inside the formview, so I put the clientidmode="static" there -> but that didn't solve my problem. Do you have any other suggestions on how I could solve this one?

Upvotes: 6

Views: 3060

Answers (1)

Adil
Adil

Reputation: 148150

You did not assign id to CompareValidator Control, You have to assign ID to asp:CompareValidator

Change

<asp:CompareValidator runat="server" Operator="DataTypeCheck"
    Type="Integer" ValidationGroup="EditValidation" Display="Dynamic"
    ControlToValidate="EinkaufsauftragsNr" ErrorMessage="Nur Ganzzahlen erlaubt."
    CssClass="validator" />

To

<asp:CompareValidator ID="SomeID" runat="server" Operator="DataTypeCheck"
    Type="Integer" ValidationGroup="EditValidation" Display="Dynamic"
    ControlToValidate="EinkaufsauftragsNr" ErrorMessage="Nur Ganzzahlen erlaubt."
    CssClass="validator" />

Upvotes: 10

Related Questions