Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > RemoveRowsFromDataTable\DataGrid

Reply
Thread Tools

RemoveRowsFromDataTable\DataGrid

 
 
eg
Guest
Posts: n/a
 
      02-22-2010
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[I];
lItem.Cells.Clear();

}

grdSW.DataSource = null;
 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      02-22-2010
On Feb 22, 2:41*pm, eg <(E-Mail Removed)> wrote:
> 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[I];
> * * * * * * *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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments