HOW TO ADD LISTVIEW ITEMS IN C#

Manoj Bhatt

Total Post:154

Points:1086
Posted by  Manoj Bhatt
C# 
C#
 1645  View(s)
Ratings:
Rate this:
Hi mindstick!

Hello I have some doubts in listveiw I have a listview with two columns, i want to add items to the first column which are given programmatically and the other column is from database... like

column1              column2

abc            from database

def                   "

 hij                    "

can this be done.... can any one help me out with this...

I am using C# ,visual studio........

thanks  in advance

  1. shreesh chandra shukla

    Post:105

    Points:735
    Re: How to add listview items in C#

    Solution!

    I'm not sure how you want to match the programmatically added values and the db values, but you could create a new listitem for each of the database values i.e.

    ListItem item = new ListItem("apple",[database value]);

    Add the items to a collection

    ItemCollection.Items.Add(item);

    Then bind the collection to your control

    ListView.DataSource = ItemCollection;

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!