RemoveRowsFromDataTable\DataGrid

  • Thread starter Thread starter eg
  • Start date Start date
E

eg

I have a datagrid, I populate with a datatable that is created and
populated at runtime, with C# code. I have a clear button on my web
form that I use to clear all the text box controls with. I also used
the code below to clear the rows in the datagrid, but after the form
does a postback the rows, with no data, are displayed again, in the
datagrid. How do I remove the rows from the datagrid?

Thanks


for (int I = 0; I < grdSW.Items.Count; I++)
{
DataGridItem lItem = grdSW.Items;
lItem.Cells.Clear();

}

grdSW.DataSource = null;
 
I have a datagrid, I populate with a datatable that is created and
populated at runtime, with C# code.  I have a clear button on my web
form that I use to clear all the text box controls with.  I also used
the code below to clear the rows in the datagrid, but after the form
does a postback the rows, with no data, are displayed again, in the
datagrid.  How do I remove the rows from the datagrid?

Thanks

   for (int I = 0; I < grdSW.Items.Count; I++)
         {
             DataGridItem lItem = grdSW.Items;
             lItem.Cells.Clear();

         }

           grdSW.DataSource = null;


I think your problem is that you bind the grid again after postback.
You can create an empty datatable/dataset and bind the grid to it.
 
Back
Top