So I have a database table called [PortfolioPerformance]
Portfolio, int, not null
AnnualReturn, decimal(18,2), not null
Closed, bit, not null
and a SqlDataSource
<asp:SqlDataSource ID="PerformanceDataSource" runat="server"
SelectCommand="SELECT [Portfolio], [AnnualReturn], [Closed] FROM [PortfolioPerformance]"/>
and a ListView
<asp:ListView ID="PerformanceListView" runat="server" DataSourceID="PerformanceDataSource">
...
<ItemTemplate>
<tr>
<td>
<asp:CheckBox ID="ClosedCheckBox" runat="server" Checked='<%# Eval("Closed") %>' Enabled="false" />
</td>
</tr>
</ItemTemplate>
And at runtime I get a HttpException "DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Closed'". If I changed the CheckBox to Checked='false', everything is fine, except the display is wrong.
I used a ListView so that users could edit the entry, and editing works fine (that is, the SqlDataSource has no problems with the insert, update, or delete statements, and using Bind("Closed") in the ListView templates doesn't throw exceptions). I've run the select statement in SQL Management Studio and it returns the correct results. Can anyone help?