Intersoft WebCombo Documentation
Walkthrough: Binding WebCombo to IList DataSource control
See Also Send comments on this topic.
Intersoft WebCombo > WebCombo Features Overview > Data Binding Wakthroughs > Walkthrough: Binding WebCombo to IList DataSource control

Glossary Item Box

This walkthrough shows you how to create and bind WebCombo to IList DataSource.

During this walkthrough, you will learn how to do the following:

 Prerequisites

In order to complete this walkthrough, you will need the following:

  • Visual Studio 2005/2008/2010 Application.

 Step-By-Step Instructions

To create new web application and bind WebCombo to IList DataSource

  1. Launch Visual Studio.NET 2005.
  2. Click on File menu, then select New and click Web Site.
  3. Select ASP.NET Web Site in the Template box and set Location to HTTP.
  4. Named the Web Site and click OK.
  5. Right-click on Project's name and select Add New Item.
  6. Select Intersoft AppForm in the My Templates box and named it as Walkthrough.aspx.
  7. Drag WebCombo instance from ToolBar to WebForm.
  8. Create a class for the database in code behind:

    C# Copy Code
    public class Invoices
    {
        private int mInvoiceId;
        private string mInvoiceNo;
        private DateTime mInvoiceDate;
        private string mCustomerName;
        private int mQty;
        private double mUnitPrice;
        private double mTotal;
    
        public Invoices(int InvoiceId, string InvoiceNo, DateTime InvoiceDate, string CustomerName, int Qty, double UnitPrice, double Total)
        {
            this.mInvoiceId = InvoiceId;
            this.mInvoiceNo = InvoiceNo;
            this.mInvoiceDate = InvoiceDate;
            this.mCustomerName = CustomerName;
            this.mQty = Qty;
            this.mUnitPrice = UnitPrice;
            this.mTotal = Total;
        }
    
        public int InvoiceId
        {
            get { return this.mInvoiceId; }
        }
    
        public string InvoiceNo
        {
            get { return this.mInvoiceNo; }
        }
    
        public DateTime InvoiceDate
        {
            get { return this.mInvoiceDate; }
        }
    
        public string CustomerName
        {
            get { return this.mCustomerName; }
        }
    
        public int Qty
        {
            get { return this.mQty; }
        }
    
        public double UnitPrice
        {
            get { return this.mUnitPrice; }
        }
    
        public double Total
        {
            get { return this.mTotal; }
        }
    }
    
    

  9. On the Page_Load event handler, write the following code:

    C# Copy Code
    protected void Page_Load(object sender, EventArgs e)
    {
       body.Style.Add("overflow", "hidden");
       ArrayList aList = new ArrayList();
    
       aList.Add(new Invoices(1, "INV-001", DateTime.Parse("2/1/2003"), "John Smith", 5, 750, 750 * 5));
       aList.Add(new Invoices(2, "INV-002", DateTime.Parse("2/2/2003"), "Steven Buchanan", 10, 450.7, 4507));
       aList.Add(new Invoices(3, "INV-003", DateTime.Parse("2/10/2003"), "Alexander King", 25, 700, 25 * 700));
       aList.Add(new Invoices(3, "INV-003", DateTime.Parse("2/10/2003"), "Alexander King", 25, 700, 25 * 700));
    
       WebCombo1.DataSource = aList;
    
       WebCombo1.DataTextField = "CustomerName";
       WebCombo1.DataValueField = "InvoiceId";
    }
    

  10. Run the project and the combo will look like following.

See Also