In the ItemDataBound Event write following code
VB.NET
Dim i As Integer = 0
If e.Item.ItemType = ListItemType.Header Then
For i = 0 To e.Item.Cells.Count -1
Me.ListBox1.Items.Add(e.Item.Cells(i).Text)
Next
End If
C#
if (e.Item.ItemType== ListItemType.Header)
{
for(int i = 0; i <= e.Item.Cells.Count-1 ; i++)
{
this.ListBox1.Items.Add(new ListItem(e.Item.Cells[i].Text));
}
}
Share with