V
VBTECH
I have a datagrid in an ASp.net application. Only one column is created at
design time, rest of the columns are created and added to grid on the fly.
When I try to update values in datagrid through UpdateCommand event code
errors out.
e.Item.Cells.Count returns 1 even though I have more columns.
Here is the sample code for creating and adding columns on the fly.
Private Sub GridLoad()
Me.grdProjDetail.AutoGenerateColumns = False
Dim ds As New DataSet
ds = ReturnDataset_StoredProc("usp_StoredProc", Param1, Param2)
Me.grdProjDetail.DataSource = ds
'Create & add columns to DataGrid
Dim col As BoundColumn
'ProjectionDetailID
col = New BoundColumn
col.DataField = "ProjectionDetailID"
Me.grdProjDetail.Columns.Add(col)
'UpdateID
col = New BoundColumn
col.DataField = "UpdateID"
Me.grdProjDetail.Columns.Add(col)
'ItemNo
col = New BoundColumn
col.DataField = "ItemNo"
Me.grdProjDetail.Columns.Add(col)
'QuarterID
col = New BoundColumn
col.DataField = "QuarterID"
Me.grdProjDetail.Columns.Add(col)
'ITEM COLOR
col = New BoundColumn
col.DataField = "ITEMCOLOR"
Me.grdProjDetail.Columns.Add(col)
Me.grdProjDetail.DataBind()
End Sub
Your help is appreciated.
design time, rest of the columns are created and added to grid on the fly.
When I try to update values in datagrid through UpdateCommand event code
errors out.
e.Item.Cells.Count returns 1 even though I have more columns.
Here is the sample code for creating and adding columns on the fly.
Private Sub GridLoad()
Me.grdProjDetail.AutoGenerateColumns = False
Dim ds As New DataSet
ds = ReturnDataset_StoredProc("usp_StoredProc", Param1, Param2)
Me.grdProjDetail.DataSource = ds
'Create & add columns to DataGrid
Dim col As BoundColumn
'ProjectionDetailID
col = New BoundColumn
col.DataField = "ProjectionDetailID"
Me.grdProjDetail.Columns.Add(col)
'UpdateID
col = New BoundColumn
col.DataField = "UpdateID"
Me.grdProjDetail.Columns.Add(col)
'ItemNo
col = New BoundColumn
col.DataField = "ItemNo"
Me.grdProjDetail.Columns.Add(col)
'QuarterID
col = New BoundColumn
col.DataField = "QuarterID"
Me.grdProjDetail.Columns.Add(col)
'ITEM COLOR
col = New BoundColumn
col.DataField = "ITEMCOLOR"
Me.grdProjDetail.Columns.Add(col)
Me.grdProjDetail.DataBind()
End Sub
Your help is appreciated.