RemoveRowsFromDataTable\DataGrid

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;
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top