BoundField in GRidView
-
I have a datatable which I would like to be able to set properties for each column to display as a gridview. I am creating a boundfield or checkboxfield etc.. for each column. These fields are set to have have there datafields from the datatable. Trouble is when i bind the datatable to the gridview I end up with boundfield version of the column and the original. How can I only show the boundfields or whatever? Hope this makes sense. I am still very new to asp.net I will include my code incase it helps.
Public Function buildGrid(ByVal DS As DataSet, ByVal ChartDetails As DataTable, ByVal GridID As Integer, ByVal TableId As Integer) As GridView
Dim Grid As New GridView
Dim oTemp As Object
Dim oboundCol As BoundField
'Declare and fill dataview
Dim dv As DataView
dv = New DataView
dv.Table = ChartDetails
Dim ColumnID As Integer
Dim DataGrid As New DataTable
DataGrid = DS.Tables(TableId - 1).Copy
dv.Sort = "ColumnID ASC"
Dim ods As New ObjectDataSourceDim ColCount As Integer = 0 While ColCount < DataGrid.Columns.Count ColumnID = ColCount + 1 dv.RowFilter = "ColumnID = '" & ColumnID & "' AND GridID = '" & GridID & "'" dv.RowStateFilter = DataViewRowState.CurrentRows oboundCol = New BoundField If dv.Count > 0 Then oboundCol.DataField = DataGrid.Columns(ColCount).ColumnName.ToString oTemp = New Object oTemp = oboundCol oTemp.HeaderText = dv.Item(0).Row.Item("Name") oTemp.ItemStyle.HorizontalAlign = HorizontalAlign.Left Else oboundCol.DataField = DataGrid.Columns(ColCount).ColumnName.ToString oTemp = oboundCol End If Grid.Columns.Add(oTemp) ColCount = ColCount + 1 End While Grid.DataSource = DataGrid Grid.DataBind() Return Grid End Function