GridView - Problem with Table.Rows.Remove( )

Discussion in 'ASP .Net Datagrid Control' started by Dev, May 2, 2007.

  1. Dev

    Dev Guest

    Hi,

    I have a gridview from which i want to remove gridviewrows onfly.
    I remove the rows as follows:

    Dim oTable as Table = CType(oGridViewRow.Parent, Table)
    oTable.Rows.Remove(CType(oGridViewRow, TableRow))

    Above removes required rows from the gridview but the problem is on
    postback, it adds blank rows again to the gridview. Is it because viewstate
    is enabled? But it doesnt add all the deleted rows but always adds one less.

    How can I control this, so that it will not add blank rows on postback?

    [The gridview is not bound to any datasource controls. So it is not possible
    to blankout databindings, delete a row from the datasource control and then
    reset bindings too.]

    Thanks.

    Dev
    Dev, May 2, 2007
    #1
    1. Advertising

  2. Dev

    Dev Guest

    Hi, further to this,

    I know I can code the Gridview_PreRender( ) event to remove blank rows again
    on a postback but is there any other better ways of accomplishing this? I
    dont like this idea because I have to loop through the grid again on the
    prerender event and delete blank rows. This will slow me down in case if my
    grid is having many rows.

    Dev

    "Dev" <> wrote in message
    news:...
    > Hi,
    >
    > I have a gridview from which i want to remove gridviewrows onfly.
    > I remove the rows as follows:
    >
    > Dim oTable as Table = CType(oGridViewRow.Parent, Table)
    > oTable.Rows.Remove(CType(oGridViewRow, TableRow))
    >
    > Above removes required rows from the gridview but the problem is on
    > postback, it adds blank rows again to the gridview. Is it because
    > viewstate
    > is enabled? But it doesnt add all the deleted rows but always adds one
    > less.
    >
    > How can I control this, so that it will not add blank rows on postback?
    >
    > [The gridview is not bound to any datasource controls. So it is not
    > possible to blankout databindings, delete a row from the datasource
    > control and then reset bindings too.]
    >
    > Thanks.
    >
    > Dev
    >
    >
    >
    Dev, May 2, 2007
    #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. Subba Rao via DotNetMonster.com

    script for moving rows up and down and traverse thru rows of HTML table

    Subba Rao via DotNetMonster.com, Mar 19, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    8,196
    Subba Rao via DotNetMonster.com
    Mar 19, 2005
  2. Rio
    Replies:
    4
    Views:
    1,172
  3. VijayRama
    Replies:
    2
    Views:
    2,292
    Gregory A. Beamer
    Oct 12, 2009
  4. Dev
    Replies:
    3
    Views:
    906
  5. Mike Solomon

    add & remove rows from table

    Mike Solomon, Jul 29, 2003, in forum: Javascript
    Replies:
    2
    Views:
    120
    Mike Solomon
    Jul 30, 2003
Loading...

Share This Page