P
Peter Kamitz
hi,
I always get the error: Item has already been added. Key in dictionary: "0"
Key being added: "0" ----when trying to databind the webgrid with
dynamically added columns.
All the columns are added without any problems, but when it comes to the
databinding (=> MyGrid.DataBind()) the error above is thrown!
here is my source code. has anybody an idea why this is not working?
private sub BindData()
Dim MyDataView As New DataView
Dim MyCol As New DataColumn
Dim MyC1Col As New C1BoundColumn
MyDataView = MyReport.GetSales()
MyGrid.AutoGenerateColumns = False
For Each MyCol In MyDataView.Table.Columns
MyC1Col.HeaderText = MyCol.ColumnName
MyC1Col.DataField = MyCol.ColumnName
MyGrid.Columns.Add(MyC1Col)
Next
MyGrid.DataSource = MyDataView
MyGrid.DataBind()
end BindData
I always get the error: Item has already been added. Key in dictionary: "0"
Key being added: "0" ----when trying to databind the webgrid with
dynamically added columns.
All the columns are added without any problems, but when it comes to the
databinding (=> MyGrid.DataBind()) the error above is thrown!
here is my source code. has anybody an idea why this is not working?
private sub BindData()
Dim MyDataView As New DataView
Dim MyCol As New DataColumn
Dim MyC1Col As New C1BoundColumn
MyDataView = MyReport.GetSales()
MyGrid.AutoGenerateColumns = False
For Each MyCol In MyDataView.Table.Columns
MyC1Col.HeaderText = MyCol.ColumnName
MyC1Col.DataField = MyCol.ColumnName
MyGrid.Columns.Add(MyC1Col)
Next
MyGrid.DataSource = MyDataView
MyGrid.DataBind()
end BindData