Re: Insert a record to a specific row
- From: "Mark McGinty" <mmcginty@xxxxxxxxxxxxxxx>
- Date: Tue, 5 Dec 2006 04:46:46 -0800
"Lou" <lou.garvin@xxxxxxxxxxx> wrote in message
news:eYoQr67FHHA.4804@xxxxxxxxxxxxxxxxxxxxxxx
I am using disconnected recordsets and binding the recordset to a grid.
I need to insert a record into the recordset to a specific position(row).
How can I achieve this?
Assuming the recordset is unsorted on the client side (i.e., rows are
displayed in the order they were returned by the data source) the only way I
can think of to achieve this is to persist the recordset to XML, and
position the new row in the node list at its desired location.
The operative node list would be that returned by
rsxml.selectSingleNode("xml/rs:data").children. You can expect, having just
inserted a record into a recordset, that its corresponding <rs:insert><z:row
..../></rs:insert> node will be at the end of the node list resolved. Remove
that node, saving it to an object variable, locate the desired position in
the node list, then insert the node relative to that position.
Then create another recordset object, open it using the xml object as the
source parameter, set the grid's DataSource to that recordset, and call the
grid's ReBind method. If the number of rows is reasonably small the effect
should be reasonably seamless.
Note that you will not be able to edit the new record until after it has
been sent-up to the server, because it will not have access to its identity
value until after that.
Also note that you will not find this technique in any MS-authored "best
practices" lists (in fact I'm fairly certain they specifically advise
against it.) OTOH, it's worth pointing out that absolutely any state in
which you might find a [disconnected] recordset or any of its fields, can be
manufactured at the XML level. This effectively makes the recordset's
behavior extensible in a moderate range of scenarios... due care is advised.
-Mark
-Lou
.
- Follow-Ups:
- Re: Insert a record to a specific row
- From: Lou
- Re: Insert a record to a specific row
- References:
- Insert a record to a specific row
- From: Lou
- Insert a record to a specific row
- Prev by Date: Re: Insert a record to a specific row
- Next by Date: Re: Insert a record to a specific row
- Previous by thread: Re: Insert a record to a specific row
- Next by thread: Re: Insert a record to a specific row
- Index(es):
Relevant Pages
|