Home      |      Forum     |    Federal and State Jobs

 

DataList - Hiding repeating value in a column.

.NET Framework
ASP.NET
VB.NET
C#
ColdFusion
PHP

In this tutorial we will talk about the DataList control. The DataList control is somewhat a combination of the DataGrid and Repeater controls. It works like the Repeater control, allowing us to create templates so that it can be bound to a data source. It also allows you to edit records, much like the DataGrid control.

To use the DataList control, drag and drop the DataList control from the Toolbox in Visual Studio.NET, then bind the control to a data source.

Right click on DataList then select - Edit Template - Header and Footer Templates

 

 In Header and Footer Templates add  header labels as below

 

 Now open Item Templates

 

In Item Templates a table with 5 columns and add 5 lables as below

 

Now open HTML page by clicking HTML tab at the bottom of the form

 

Update <ItemTemplate> as below

 

We will add VB code to load DataList from SQL Server:

Imports System.Data.SqlClient

 

Lets run this page. We will see repated values in the OrderID column. 

Add the VB code below for DataList_ItemBound to hide repeated values

 

 Now we will see the output as below
 

Join WebHost4Life.com