Wednesday, June 27, 2018

Create new headers for your DataGrid with the DataGridItem object ASP NET

Create new headers for your DataGrid with the DataGridItem object ASP NET


If youd like to create new DataGrid headers to visually separate your grid rows, you can do so quite easily with the DataGridItem object. Creating new DataGrid headers with this object is a three-step process. You start with a new DataGridItem object. Then, you add Cells to the DataGridItem, and finally you add the DataGridItem to the DataGrid, like so:

Dim dgItem As DataGridItem
dgItem = New DataGridItem(0, 0, ListItemType.Header)

Dim dgCell As TableCell
dgCell = New TableCell
dgCell.Text = "someval"

dgItem.Cells.Add(dgCell)

DataGrid1.Controls(0).Controls.AddAt(0, dgItem)


This code creates a new DataGrid header with one table cell and adds it to the first row of DataGrid1 on a Web form.



visit link download