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?
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" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With