Click here to Skip to main content
11,565,382 members (40,091 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C#4.0
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

Advertise | Privacy | Mobile
Web03 | 2.8.150624.2 | Last Updated 6 Feb 2013
Copyright © CodeProject, 1999-2015
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