RemoveRowsFromDataTable\DataGrid

Discussion in 'ASP .Net' started by eg, Feb 22, 2010.

  1. eg

    eg 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;
     
    eg, Feb 22, 2010
    #1
    1. Advertising

  2. On Feb 22, 2:41 pm, eg <> 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;
    >              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.
     
    Alexey Smirnov, Feb 22, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave
    Replies:
    0
    Views:
    475
  2. BK Kim

    datagrid in datagrid

    BK Kim, Feb 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    573
    Alvin Bruney [MVP]
    Mar 2, 2004
  3. =?Utf-8?B?U3VyZXNo?=
    Replies:
    0
    Views:
    547
    =?Utf-8?B?U3VyZXNo?=
    Mar 2, 2004
  4. Brian K. Williams
    Replies:
    0
    Views:
    561
    Brian K. Williams
    Mar 2, 2004
  5. Andreas Klemt
    Replies:
    0
    Views:
    334
    Andreas Klemt
    Oct 8, 2003
Loading...

Share This Page