Solved

listview just displaying four items

Posted on 2013-06-03
5
313 Views
Last Modified: 2013-06-04
Hi,

I have a listview which should be displaying all the records from the database.  But it keeps displaying only 4 records that too recently added. it ignores all the previous items.  Any idea how to resolve this?

HEre is the code for it.
  Try
         
            If d.ditems.Count > 0 Then


             
                Dim foo As String
                Dim foo1() As String
                Dim item As ListViewItem
                lvfoo.Items.Clear()
                'For Each foo In d.ditems
         
                    foo1 = foo.Split("|")
                    item = New ListViewItem(foo(0))
                    Me..Items.Add(item)
                    item.SubItems.Add(foo(1))
                    item.SubItems.Addfoo(2))

                    'item = Nothing
                Next
            End If
        Catch ex As Exception
            SystemException(ex.ToString)
        End Try

Open in new window

0
Comment
Question by:developer2012
  • 2
  • 2
5 Comments
 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 39218122
Hi,

Can you check the value of d.ditems.Count? How do you populate the items in d.ditems.count?
0
 

Author Comment

by:developer2012
ID: 39218136
I am populating the values from database.
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39218204
the ode u posted is not compiled and also has a logic error in it.
i assume d.ditems contains the data from database?
did u debug the code and check how many records are they?
u can using linq, to add the records to the listview without iterating the items:
  Try
         
            If d.ditems.Count > 0 Then

                lvfoo.Items.Clear()
        Dim items As ListViewItem() = d.ditems.Select(Function(item) New ListViewItem(item.Split("|").ToArray))
        lvfoo.Items.AddRange(items)
            End If
        Catch ex As Exception
            SystemException(ex.ToString)
        End Try

Open in new window

0
 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 39218366
Can you show us the code on how you populate the d.ditems?
0
 

Author Comment

by:developer2012
ID: 39219077
Fixed.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now