0
Reply

Datagrid loses columns during edit

rickwhite_tx

rickwhite_tx

Jul 9 2004 12:21 PM
1.5k
I have a datagrid populated in the following manner; 'This subroutine populates the dataset -- properly general.DoCommand(cmdNdx, dsDataset, , strRTN) 'To navigate through the dataset records and set the bound columns For i = 0 To dsDataset.Tables(0).Columns.Count - 1 Dim objbc As New BoundColumn objbc.DataField = dsDataset.Tables(0).Columns(i).ColumnName objbc.HeaderText = dsDataset.Tables(0).Columns(i).ColumnName If InStr(strRTN, objbc.DataField) > 0 Then objbc.Visible = False End If DataGrid1.Columns.Add(objbc) Next DataGrid1.DataSource = dsDataset DataGrid1.Visible = True DataGrid1.Enabled = True DataGrid1.GridLines = GridLines.Both DataGrid1.ItemStyle.BackColor = _ System.Drawing.Color.AntiqueWhite DataGrid1.AlternatingItemStyle.BackColor = _ System.Drawing.Color.LightBlue DataGrid1.HeaderStyle.BackColor = _ System.Drawing.Color.Blue DataGrid1.HeaderStyle.ForeColor = _ System.Drawing.Color.White 'Following test is valid for only the directory and 'user list ... need to define a better algorithm If Val(Session("user_authority_level")) > 224 Then 'Admin or Superuser can edit and delete DataGrid1.Columns.Item(0).Visible = True DataGrid1.Columns.Item(1).Visible = True Else DataGrid1.Columns.Item(0).Visible = False DataGrid1.Columns.Item(1).Visible = False End If DataGrid1.DataBind() The columns display properly. The dataset that I am working with has 6 columns. I have added an edit and delete column to the datagrid in the "Property Builder". After the databind had executed, the datagrid has 8 columns. The user clicks the EDIT button on the row that he wants to edit. The UPDATE handler runs, and the datagrid has only 2 columns. Is my problem that I did not edit the webform and add BOUNDCOLUMN fields to the ASP code? I hope not, I'm trying to make a general usage datagrid that I can use for all of my functions.