Pages

Thursday, August 23, 2012

Add a Separator to a DataGrid control using a DataGridItem object (ASP.NET)

Have you ever wanted to add a visual separator to your DataGrid? You can easily do so by creating a new DataGridItem object with an ItemType of Separator, like we've done here:

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

Then, you simply add the separator to your DataGrid using code similar to the following:

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

This code adds a separator line above the second row in a DataGrid. Remember to take the DataGrid header into account when you specify an index for the AddAt method.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.