CompareValidator with DataTypeCheck and dynamically set Type

G

Guest

The following works...

<asp:CompareValidator
Runat="server"
ControlToValidate="txtValue"
Text="*"
ErrorMessage="The value you provided is not of the correct type."
Operator="DataTypeCheck"
Type='Double'
/>

.... and the following doesn't ...

<asp:CompareValidator
Runat="server"
ControlToValidate="txtValue"
Text="*"
ErrorMessage="The value you provided is not of the correct type."
Operator="DataTypeCheck"
Type='<%# DataBinder.Eval(Container.DataItem,"ASPType") %>'
/>

.... even though I have checked that DataBinder.Eval(Container. DataItem ,
"ASPType") is evaluating to the string value "Double".

The error is pretty cryptic. Here's a part of the trace...

FormatException: Input string was not in a correct format.]
Microsoft.VisualBasic.CompilerServices.DoubleType.Parse(String Value,
NumberFormatInfo NumberFormat)
Microsoft.VisualBasic.CompilerServices.DoubleType.Parse(String Value)
Microsoft.VisualBasic.CompilerServices.IntegerType.FromString(String Value)

[InvalidCastException: Cast from string "Double" to type 'Integer' is not
valid.]
Microsoft.VisualBasic.CompilerServices.IntegerType.FromString(String Value)
Microsoft.VisualBasic.CompilerServices.IntegerType.FromObject(Object Value)

Can anyone help me understand what I'm doing wrong?

Thanks!

Keith Spitz
Wall Street on Demand, Inc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top