RE: Inserting subtotal rows into a datatable

From: Steven Cheng[MSFT] (v-schang_at_online.microsoft.com)
Date: 11/08/04


Date: Mon, 08 Nov 2004 03:32:41 GMT

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. ... > DataTable will reflect the correct rows order in the collection. ... > verify whether the actual order in the Rows collection is correct. ... > in the following loop ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: S10 sshd X forwarding problem
    ... X11 display socket. ... Looks like the fix for CR 6684003 breaks sshd's ability to bind to a local ... if on the remote host I touch hostname6.lo0 I get the remote display. ...
    (comp.unix.solaris)
  • Re: S10 sshd X forwarding problem
    ... X11 display socket. ... Looks like the fix for CR 6684003 breaks sshd's ability to bind to a local ... if on the remote host I touch hostname6.lo0 I get the remote display. ...
    (comp.unix.solaris)
  • Re: S10 sshd X forwarding problem
    ... X11 display socket. ... Looks like the fix for CR 6684003 breaks sshd's ability to bind to a local ... if on the remote host I touch hostname6.lo0 I get the remote display. ...
    (comp.unix.solaris)
  • RE: First record of datagrid not showing
    ... from database and bind them in a webform datagrid so as to populate in a ... records in page's output (rather than bind to datagrid) to confirm this. ... can add some break points in the datagrid's ItemDataBound event since each ... can see whether the first record is actually binded or not. ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)