N
Nikolay Petrov
I have a DataSet with one DataTable in it.
When binded to a DataGrid, a get the column names in DataTable as headers
for the columns in the DataGrid.
When I created the DataColumns I set their Caption property, but it doesn't
want to show as Column header in the DataGrid. What I do wrong?
Code:
Dim DS1 As New DataSet
Dim dT As New DataTable("Table Name")
Dim dCol As DataColumn
dCol = New System.Data.DataColumn("Col1")
dCol.DataType = System.Type.GetType("System.String")
dCol.Caption = "Column 1"
dT.Columns.Add(dCol)
dCol = New System.Data.DataColumn("Col2")
dCol.DataType = System.Type.GetType("System.String")
dCol.Caption = "Column 2"
dT.Columns.Add(dCol)
DS1.Tables.Add(dT)
DataGrid1.DataSource = DS1.Tables(0)
DataGrid1.DataBind
When binded to a DataGrid, a get the column names in DataTable as headers
for the columns in the DataGrid.
When I created the DataColumns I set their Caption property, but it doesn't
want to show as Column header in the DataGrid. What I do wrong?
Code:
Dim DS1 As New DataSet
Dim dT As New DataTable("Table Name")
Dim dCol As DataColumn
dCol = New System.Data.DataColumn("Col1")
dCol.DataType = System.Type.GetType("System.String")
dCol.Caption = "Column 1"
dT.Columns.Add(dCol)
dCol = New System.Data.DataColumn("Col2")
dCol.DataType = System.Type.GetType("System.String")
dCol.Caption = "Column 2"
dT.Columns.Add(dCol)
DS1.Tables.Add(dT)
DataGrid1.DataSource = DS1.Tables(0)
DataGrid1.DataBind