VKinfotek Inc.
  • Us
    About Us
    Contact Us
  • FAQs
  • Ready Software
    Ready ERP ASP Core Software for Azure Cloud
    Ready Web ERP Software
    Ready ASP.Net Azure Software
    Ready C# SQL Server Accounting Software
    Ready ASP.Net MVC and EF Software
First slide
Earn $100/hour in USA! Click Here

bind arraylist with gridview control in asp net application

In this article, we will create an ArrayList of Item objects and bind it to a GridView control using DataSource property.

Steps:



We will create a class named Item as shown below. In the Page_Load method, we will create an ArrayList and add items to the arraylist using Add method. Now we will bind the arrayList using GridView.DataSource property.

public class Item
 {
     private string strCode;
     private string strName;
     public Item(string code, string name)  
     {
        this.strCode = code;
        this.strName = name;            
     }      
 	public string Code     
    {        
      get 
      {   return this.strCode;    }      
    }
    public string Name
    {
       get
       {    return this.strName; }
       }
    }
}
protected void Page_Load(object sender, EventArgs e)
 {
    ArrayList list = new ArrayList();
    list.Add(new Item("I001", "Item1"));
    list.Add(new Item("I002", "Item2"));
    list.Add(new Item("I003", "Item3"));
    list.Add(new Item("I004", "Item4"));
    GridView1.DataSource = list;
    GridView1.DataBind();
 }




  • SITEMAP
  • Terms of use
  • Testimonials

Back to top

Copyright © 2016 - All Rights Reserved - VKInfotek.com