FormView Checkbox Binding Problem
I am using a FormView to display data from a SQL database, when I try to bind a checkbox开发者_如何学JAVA to a field in the database that contains only true or false in the value (NONE OF THE VALUES ARE NULL). I get the error "Specified cast is not valid" Ive tried Eval
and Bind
and neither work both produce the same error anyone know what the problem might be?
<asp:CheckBox ID="IVT" runat="server"
Checked='<%# Eval("ContactInvite") %>' />
The values that are in every row is exactly "true" or "false" no 1 or 0 or "T" of "F". They are stored in a varchar column in the database.
You can use Eval in this manner:
<asp:CheckBox ID="IVT" runat="server"
Checked='<%# Eval("ContactInvite").ToString() == "True" %>' />
Does the ContactInvite column only contain TRUE/FALSE values as strings? If they are 0/1 or T/F then setting the property wont work. Can you provide us with the values that the ContactInvite field contains?
精彩评论