When I was creating a datasource for the List box - it showed the correct data,
but when I tested it on the Web - I see a listbox with 3 lines of value:
"System.Data.DataRowView". After manually deleting a row from the database - I see
only 2 lines. After deleting all rows from the table - the listbox is empty.
So why I don't see the table values, but the string "System.Data.DataRowView"?
Member
10 Points
21 Posts
System.Data.DataRowView in list box (instead of data)
Feb 17, 2011 02:30 PM|zalek|LINK
On my .aspx code I have
<asp:ListBox ID="LBcategories" runat="server"
DataSourceID="SQLCategories">
</asp:ListBox>
<asp:SqlDataSource ID="SQLCategories" runat="server"
ConnectionString="<%$ ConnectionStrings:boss2ConnectionString %>"
SelectCommand="SELECT [category_name] FROM [Categories]">
</asp:SqlDataSource>
When I was creating a datasource for the List box - it showed the correct data,
but when I tested it on the Web - I see a listbox with 3 lines of value:
"System.Data.DataRowView". After manually deleting a row from the database - I see
only 2 lines. After deleting all rows from the table - the listbox is empty.
So why I don't see the table values, but the string "System.Data.DataRowView"?
Thanks
Zalek
All-Star
88260 Points
9668 Posts
Re: System.Data.DataRowView in list box (instead of data)
Feb 17, 2011 02:41 PM|ecbruck|LINK
You need to define both the DataTextField and DataValueField properties of your ListBox.