Thursday, March 29, 2012

Manually specifying columns in a datagrid

Hi, I have a dataview that 'views' some information returned by a dataset.

I can autobind a datagrid to the view so that all information is automatically populated within the datagrid.

What I wuld like to do is specify the column headers as well as their associated attribute in the dataset via code.

e.g datagrid.columns.add(....

thanks for any help/ advice

MarkusJTry something like this:


Dim dt As New DataTable
Dim ds as new DataSet
Dim dc as DataColumn()
dc = New DataColumn()
dc.ColumnName = "Index"
dc.DataType = System.Type.GetType("System.Int16")
dc.ReadOnly = True
dt.Columns.Add(dc)
ds.Tables.Add(dt)
DataGrid1.DataSource = ds
DataGrid1.DataBind()

Hope this helps ya,
Cool thanks :)

0 comments:

Post a Comment