I want to find the total number of active users who are members of the user table in my database. But I get an error like this:
DataBinding:'System.Data.DataRowView' does not contain a property with name 'userid'.
My code is as follows:
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<h3><%#Eval("userid") %></h3>
</ItemTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:aytasarimConnectionString %>" SelectCommand="SELECT COUNT([userid]) FROM [user] WHERE ([isactive] = @isactive)">
<SelectParameters>
<asp:Parameter DefaultValue="True" Name="isactive" Type="Boolean" />
</SelectParameters>
</asp:SqlDataSource>
Your select command not including
userid
field. You can change your command asthen
Eval
can find this column from your data source.