Hello I have been having trouble with this for a while now.
I have a bound textbox within a DetailsView that I have added a RegularExpressionValidator to. However after running the Web form I discovered that the value is never considered valid even when it should be. The field should only validate when the value is empty or exactly 3 uppercase letters. If I enter 'CBA' which should work I'm getting this expression as the errormessage: ^[A-Z]ABC$
where ABC is the value the field has from the datasource. So I guess it has something to do with the Eval() function inside the DetailsView but I fail to understand what exactly and how to avoid it.
<EditItemTemplate>
<asp:TextBox ID="TBDepartFrom" runat="server" Text='<%# Bind("DepartFrom") %>'>
</asp:TextBox>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator1" ControlToValidate="TBDepartFrom"
runat="server"
ErrorMessage="This code is invalid!"
Text='<%# Eval("DepartFrom", "^[A-Z]{3}$") %>'>
</asp:RegularExpressionValidator>
</EditItemTemplate>