Programmatically Setting the Header and Footer Text of a Datagrid September 30 2005
Suppose you wish to create a datagrid programmatically such as:
…
Dim dg as new DataGrid
…
The usual method of binding existing data to this grid is like:
…
dg.datasource = dvMyDataView
dg.databind
…
I have come across the need to add footer data to the datagrid however I first tried to inject the row with my values.
The key to header and footer data at runtime in .NET is column declarations!
When you create a datagrid by hand, create each column individually such as:
…
Dim datagridcol As New BoundColumn
datagridcol.HeaderText = “Market”
datagridcol.DataField = “Application”
dg.Columns.Add(datagridcol)
…
Once you have defined each column, then do the data bind.
- Posted in : .NET
- Author : site admin

Comments
Sorry comments are closed for this entry