Reputation: 1027
Good day, just a quick question: I would like to bind a table to a checkboxlist control, so I did this in the Page_Load method:
CBL_categ.DataSource = FilmsAccess.Pop_check();
CBL_categ.DataBind();
I specify that Pop_check
returns a table of one column.
When I run, instead of the values in that column, I see "System.Data.DataRowView"
a number of times, with the check boxes. I also tried:
CBL_categ.DataSource = FilmsAccess.Pop_check().Column[0];
but it gives this error: Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource.
Thanks a lot. Anna
EDIT: Here's the Pop_check() method at request:
public static DataTable Pop_check()
{
DbCommand com = GenericDataAccess.CreateCommand();
com.CommandText = "Catalog_CBL";
DataTable table = GenericDataAccess.ExecuteSelectCommand(com);
return table;
}
Upvotes: 0
Views: 1444
Reputation: 38
In the ASCX file bind following two field, preferably by name
<asp:CheckBoxList ID="cblMyList" runat="server"
DataTextField="ID" DataValueField="ID"></asp:CheckBoxList>
Upvotes: 1