Delay in Listview Binding using SqDatareader in windows application
-
Hi All, I have developed a windows application,have a listview in one form... Given below is the code to bind the listview :- Dim sqlCmd As SqlCommand = New SqlCommand("Select Query") Dim myData As SqlDataReader Dim lvhHelper As ListViewData = New ListViewData() Try If _con.State = ConnectionState.Open Then _con.Close() End If _con.Open() sqlCmd.Connection = _con myData = sqlCmd.ExecuteReader lvhHelper.FillListView(LstItems, myData) _con.Close() And below is the FillListView Class file Dim lvwColumn As ColumnHeader Dim itmListItem As ListViewItem Dim strTest As String Dim shtCntr As Short MyListView.Clear() For shtCntr = 0 To myData.FieldCount() - 1 lvwColumn = New ColumnHeader() lvwColumn.Text = myData.GetName(shtCntr) lvwColumn.Width = "100" MyListView.Columns.Add(lvwColumn) Next 'lvwColumn = Nothing Do While myData.Read itmListItem = New ListViewItem() strTest = IIf(myData.IsDBNull(0), "", myData.GetValue(0).ToString) itmListItem.Text = strTest For shtCntr = 1 To myData.FieldCount() - 1 If myData.IsDBNull(shtCntr) Then itmListItem.SubItems.Add("") Else itmListItem.SubItems.Add(myData.GetValue(shtCntr).ToString) End If Next shtCntr MyListView.Items.Add(itmListItem) Loop by using this codes listview is getting binded very slowly and will be blank hile loading... is there anything wrong i did in this code?.. any otherway to bind the listview using datareader?.. Thanks in Advance..