W
WebBuilder451
I'm attempting to dynamicly populate a bound gridview.
The first step is to clear all columns except for column 0.
for (int i = gvPreview.Columns.Count-1; i > 0; i--)
gvPreview.Columns.RemoveAt(i);
Second step is to add the selected bound fields using a check id as the
boundfield name. The check boxes are loaded into a list of controls.
foreach (Control Ctrl in ControlList)
if (((CheckBox)Ctrl).Checked)
{
BoundField bFld = null;
bFld = new BoundField();
bFld.DataField = Ctrl.ID.ToString();
bFld.HeaderText = Ctrl.ID.ToString();
gvPreview.Columns.Add(bFld);
}
so far it works.
on load the grid a blanlk except for a single check box in a template, this
is column 0.
After the check boxes are selected and loaded into a list the code above is
executed.
on first try it works fine. Even if i add an extra control to force a column
removeAt to be called
on second try the control is removed from column 0, but not the column. It
is like the column is being cleared of all its controls.
Note: This ony happens if it is a template column.
Is this a bug and is there a work around?
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)
kes
The first step is to clear all columns except for column 0.
for (int i = gvPreview.Columns.Count-1; i > 0; i--)
gvPreview.Columns.RemoveAt(i);
Second step is to add the selected bound fields using a check id as the
boundfield name. The check boxes are loaded into a list of controls.
foreach (Control Ctrl in ControlList)
if (((CheckBox)Ctrl).Checked)
{
BoundField bFld = null;
bFld = new BoundField();
bFld.DataField = Ctrl.ID.ToString();
bFld.HeaderText = Ctrl.ID.ToString();
gvPreview.Columns.Add(bFld);
}
so far it works.
on load the grid a blanlk except for a single check box in a template, this
is column 0.
After the check boxes are selected and loaded into a list the code above is
executed.
on first try it works fine. Even if i add an extra control to force a column
removeAt to be called
on second try the control is removed from column 0, but not the column. It
is like the column is being cleared of all its controls.
Note: This ony happens if it is a template column.
Is this a bug and is there a work around?
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)
kes