How to retrieve data from database and display it in Listview
-
Hi, i got a problem with my application. Usually I retrieve data from database and display it in datagrid. But, how to display data in Listview. Thanx b4 Best Regards Edwin46 :)
-
Hi, i got a problem with my application. Usually I retrieve data from database and display it in datagrid. But, how to display data in Listview. Thanx b4 Best Regards Edwin46 :)
Hi, In ListView you will have to Enumerate the datasource and fill it. For example, if your datasource is a DataTable, you can write the following: foreach(DataRow row in table.Rows) { ListViewItem item = new ListViewItem(); item.Text = row["Description"].ToString(); item.Tag = row["ID"].ToString(); //For other coulmns items.SubItems.Add(row["OtherColumn"].ToString(); } Hope this helps.
-
Hi, i got a problem with my application. Usually I retrieve data from database and display it in datagrid. But, how to display data in Listview. Thanx b4 Best Regards Edwin46 :)
u have to get the records through datareader and then iterate through the datareader and add them in the listview one by one if u use listbox in place of listview then u can use the datasource,displaymember,valuemember properties by doing this u can easily bind the data