ComponentOne TabStrip for ASP.NET AJAX: TabStrip for ASP.NET AJAX Task-Based Help > Binding a C1TabStrip to a Data Source > Binding a C1TabStrip to an IEnumerable Data Source

Binding a C1TabStrip to an IEnumerable Data Source

In this topic, you will learn how to create an IEnumerable data source and bind it to a C1TabStrip.

Note:  When a C1TabStrip is bound to an IEnumberable data source, no hierarchy will exist;  this is flat databinding, therefore only root items can be created.

Complete the following steps:

1.   Create a new ASP.NET AJAX-Enabled Web Site in Visual Studio.

2.   Add a C1TabStrip to your project.

3.   Double-click your project page to add Page_Load event to your code and open the code editor.

4.   Import the following namespaces into your program:

      Visual Basic

Imports System.Collections

Imports C1.Web.UI.Controls.C1TabStrip

      C#

using System.Collections;

using C1.Web.UI.Controls.C1TabStrip;

5.   Create an ArrayList and add it to your code by placing the following code within the _Default class but outside of the Page_Load event:

      Visual Basic

Private Function CreateArrayList() As ArrayList

    Dim list As New ArrayList()

   'Add items to the ArrayList and create your tab objects  

    list.Add(New C1Tab("Books"))

    list.Add(New C1Tab("Computer Games"))

    list.Add(New C1Tab("Movies"))

    list.Add(New C1Tab("Music"))

    list.Add(New C1Tab("Other"))

    Return list

End Function

      C#

private ArrayList CreateArrayList()

{

   ArrayList list = new ArrayList();

   \\ Add items to the ArrayList and create your tab objects 

   list.Add(new C1Tab("Books"));

   list.Add(new C1Tab("Computer Games"));

   list.Add(new C1Tab("Movies"));

   list.Add(new C1Tab("Music"));

   list.Add(new C1Tab("Other"));

   return list;

}

6.   Set the DataSource property and bind the array list data to your C1TabStrip by copying the following code into the Page_Load event:

      Visual Basic

C1TabStrip1.DataSource = CreateArrayList()

C1TabStrip1.DataBind()

      C#

C1TabStrip1.DataSource = CreateArrayList();

C1TabStrip1.DataBind();

7.   Run the program.

 This Topic Illustrates the Following:

After you run the program, observe that the tabs of the C1TabStrip now reflect the information that you entered in code view. Your result will resemble the following image:

 


Send comments about this topic to ComponentOne.
Copyright © 1987-2010 ComponentOne LLC. All rights reserved.