Re: Inserting subtotal rows into a datatable

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: GaryB (gb_at_nospam.com)
Date: 11/08/04


Date: Mon, 8 Nov 2004 09:32:09 -0800

Sorry for wasting your time. it was a bogus issue. The code was working
fine - I was just looking at the wrong output.
Gary

"Steven Cheng[MSFT]" <v-schang@online.microsoft.com> wrote in message
news:2FrxfOUxEHA.1288@cpmsftngxa10.phx.gbl...
> Hi Gary,
>
> From your description, you're using the InsertAt method of
> DataRowCollection to insert new rows into a manually generated DataTable
> and then bind it onto a webform datagrid. However, you found the new added
> rows always display at the bottom of the datagrid, yes?
>
> As John has mentioned, the means how to bind the datatable to the grid may
> also change the display order since Only the raw "Rows" collection of the
> DataTable will reflect the correct rows order in the collection. If we use
> some other methods such as Select() or GetChildRows to retreive datarows
> from DataTable, the retuned rows may not represent the actual order in the
> Rows collection. So would you provide some info on how you bind the
> DataTable onto the grid? Also, I suggest you manually use
> for(i=0;i<Table.Rows.Count; i++)
> ...
>
> to printout all the rows in the DataTable after you inserting new rows to
> verify whether the actual order in the Rows collection is correct.
>
> In addition, from the code you provided, seems you will insert new rows
> in the following loop
>
> For i = 0 To dsDisplay.Tables(0).Rows.Count - 1
> Dim row As DataRow = dsDisplay.Tables(0).Rows(i)
>
> That may cause the Table's Rows Collection be modified during the for
> loop
> and thus the "i" iterate index may point to the incorrect record. Not sure
> whether this will also be the potential cause of this issue.
>
> Hope helps. If you have any other findings , please also feel free to post
> here. thanks.
>
> Regards,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>



Relevant Pages

  • RE: Inserting subtotal rows into a datatable
    ... and then bind it onto a webform datagrid. ... the means how to bind the datatable to the grid may ... also change the display order since Only the raw "Rows" collection of the ... verify whether the actual order in the Rows collection is correct. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Copying datatable contents to another datatable
    ... (same fields, same types, same sequence ... I normally use a for each loop on the source table's rows collection then ... DataTable.ImportRow on the destination table. ...
    (microsoft.public.dotnet.languages.csharp)