Click here to Skip to main content
13,201,920 members (72,509 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hello All,

I am working on a windows application and I have a datatable that is having some data. While I am adding the data to the list view in a form its only adding one column value not all column values. Please help me.

DataTable dt = new DataTable();
            dt = myService.GetLeaveDetails();
            for (int i = 0; i < dt.Rows.Count; i++)
                lvLeaveDetails.Columns.Add("Column " + i.ToString());
            foreach (DataRow row in dt.Rows)
                string[] subitems = new string[dt.Rows.Count];
                object[] o = row.ItemArray;
                for (int i = 0; i < dt.Columns.Count; i++)
                    subitems[i] = o[i].ToString();
                ListViewItem item = new ListViewItem(subitems);

Posted 6-Feb-13 1:48am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171020.1 | Last Updated 6 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100