ListView binding to DataTable...
I have a DataTable with three columns (Name, CasesToday, CasesWeek) and a ListView with a View of GridView. I need to bind the ListView to display the contents of the DataTable at runtime. I have tried gvUsers.ItemsSource = dtUsers2.DefaultView; but this only shows "System.Data...." and not the actual value from the row. I have scoured the Internet for the solution to this but can only find SQL and XML binding; none the reference DataTables. Any help would be much appreciated.
Sam HobbsPosted Nov 6, 2009, 1:49 PM
JosephPosted Nov 6, 2009, 1:09 PM
Sam HobbsPosted Nov 6, 2009, 12:47 PM
ListView1.DataSource = dt;
Where dt is the DataTable.
Amit ChoudharyPosted Nov 6, 2009, 12:43 AM
and in the codebehind bind like this ListView1.DataSource=Dtable; ListView1.DataBind();
romelevansPosted Nov 5, 2009, 7:37 PM
Sam HobbsPosted Nov 5, 2009, 1:03 PM
Look at the Data Walkthroughs to see what can be done. You don't need to do the walkthroughs in any order; do the ones you want to in the order you want to. Most of the walkthroughs use the DataGridView, which is like a ListView, but the general concepts are the same for both. My guess is that you will decide to use a DataGridView instead.