Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. How to bind Listview to Ilist

How to bind Listview to Ilist

Scheduled Pinned Locked Moved WPF
tutorial
5 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chandra vempati
    wrote on last edited by
    #1

    i have a small rec in which i have to bind the listview with the Ilist which is a generic collection.

    cheers chandu

    M A 2 Replies Last reply
    0
    • C chandra vempati

      i have a small rec in which i have to bind the listview with the Ilist which is a generic collection.

      cheers chandu

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      Data Binding Overview: Binding to Collections[^]

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      1 Reply Last reply
      0
      • C chandra vempati

        i have a small rec in which i have to bind the listview with the Ilist which is a generic collection.

        cheers chandu

        A Offline
        A Offline
        amistry_petlad
        wrote on last edited by
        #3

        create on class like product and do the following things using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public class Product { private string _productName; public string ProductName { get { return this._productName; } set { this._productName = value; } } public Product() { } } -------------------- then create other calls public class ProductRepository { public static IList GetProducts(string criteria) { string key = "Products_" + criteria[0]; IList list = CacheRepository.GetObjects(key); if (list == null || list.Count == 0) { list = DataAccess.GetProducts(criteria); CacheRepository.SaveObject(key, list); } // return the list based on the criteria List productList = list as List; list = productList.FindAll(delegate(Product product) { return product.ProductName.ToLower().StartsWith(criteria.ToLower()); }); return list; } } ------------------------------- public class DataAccess { public static IList GetProducts(string criteria) { List list = new List(); // Fill the list with any data source while (reader.Read()) { Product product = new Product(); product.ProductName = reader["name1"] as String; list.Add(product); //which fill the list } } return list; } } ------------------------------ Then in the Page_Load or any method you can bind this way IList list = null; Listview listview = new Listview(); listview.DataSource = list; listview.DataBind();

        C 1 Reply Last reply
        0
        • A amistry_petlad

          create on class like product and do the following things using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public class Product { private string _productName; public string ProductName { get { return this._productName; } set { this._productName = value; } } public Product() { } } -------------------- then create other calls public class ProductRepository { public static IList GetProducts(string criteria) { string key = "Products_" + criteria[0]; IList list = CacheRepository.GetObjects(key); if (list == null || list.Count == 0) { list = DataAccess.GetProducts(criteria); CacheRepository.SaveObject(key, list); } // return the list based on the criteria List productList = list as List; list = productList.FindAll(delegate(Product product) { return product.ProductName.ToLower().StartsWith(criteria.ToLower()); }); return list; } } ------------------------------- public class DataAccess { public static IList GetProducts(string criteria) { List list = new List(); // Fill the list with any data source while (reader.Read()) { Product product = new Product(); product.ProductName = reader["name1"] as String; list.Add(product); //which fill the list } } return list; } } ------------------------------ Then in the Page_Load or any method you can bind this way IList list = null; Listview listview = new Listview(); listview.DataSource = list; listview.DataBind();

          C Offline
          C Offline
          chandra vempati
          wrote on last edited by
          #4

          I am using Nhibernate. how to get data from database , assign the result set to the Ilist and bind that Ilist to the ListView in wpf. thanks for your reply... its helpful

          cheers chandu

          A 1 Reply Last reply
          0
          • C chandra vempati

            I am using Nhibernate. how to get data from database , assign the result set to the Ilist and bind that Ilist to the ListView in wpf. thanks for your reply... its helpful

            cheers chandu

            A Offline
            A Offline
            amistry_petlad
            wrote on last edited by
            #5

            why you can not bind the data directly to the listview rather then putting it into IList is there any specific reason? let me know so I can help you better. ;) Will this may be helpful? http://www.theserverside.net/tt/articles/showarticle.tss?id=NHibernate[^]

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups