Home All Groups Group Topic Archive Search About
Author
9 Mar 2005 12:37 PM
Steve
This may be a common question, however I didn't find any posts on the issue.
When you are editing a row of a datagrid, and then you sort the datagrid, the
edititemindex stays the same, which means that you are now editing a
different item (though the same physical row of the datagrid).  How can you
make it so that you are still editing the same data after you sort?  As it
is, I am simply clearing the edititemindex.  (By the way, this issue also
applies when using the selecteditemindex.)

Your help is appreciated, thank you.

Author
9 Mar 2005 1:27 PM
Elton Wang
Hi Steve,

I suppose you have to implement your own code to solve the
problem. You may use following logic.

When sorting
If edititemindex <> -1 then
    Find PK data from edit item
Endif
Sort data source and assign it to datagrid
Find index from PK data
Assign edititemindex = the index
Call datagrid.DataBind


HTH

Elton Wang
elton_w***@hotmail.com

>-----Original Message-----
>This may be a common question, however I didn't find any
posts on the issue.
>When you are editing a row of a datagrid, and then you
sort the datagrid, the
>edititemindex stays the same, which means that you are
now editing a
>different item (though the same physical row of the
datagrid).  How can you
>make it so that you are still editing the same data after
you sort?  As it
>is, I am simply clearing the edititemindex.  (By the way,
this issue also
Show quoteHide quote
>applies when using the selecteditemindex.)
>
>Your help is appreciated, thank you.
>.
>
Author
13 Mar 2005 11:17 PM
Scott M.
You'll have to know the index of the row in the dataset.  Unfortunately, the
DataSetIndex property doesn't provide this accurately after you have sorted,
so you'll need to find the record manually in the dataset and then get its'
index.  You can use the Select method and pass a SQL like search criteria to
help you find the record in the DataSet.


Show quoteHide quote
"Steve" <St***@discussions.microsoft.com> wrote in message
news:FD1EF1F4-008C-4D96-B7C1-9C66FE71B9DA@microsoft.com...
> This may be a common question, however I didn't find any posts on the
> issue.
> When you are editing a row of a datagrid, and then you sort the datagrid,
> the
> edititemindex stays the same, which means that you are now editing a
> different item (though the same physical row of the datagrid).  How can
> you
> make it so that you are still editing the same data after you sort?  As it
> is, I am simply clearing the edititemindex.  (By the way, this issue also
> applies when using the selecteditemindex.)
>
> Your help is appreciated, thank you.