Re: moving record in datagrid

From: Earl (brikshoe_at_newsgroups.nospam)
Date: 11/26/04


Date: Fri, 26 Nov 2004 01:55:43 -0500

Kinda reminds me of the question, how high is "up". By what criteria does a
row exist in a "higher" or "lower" position exist in a table in your
database? Theory would say none at all. BUT, the results from your database
can be determined by sort order. So the seminal question becomes: what field
do you want to sort by?

Obviously the "rows" in a datagrid have to be ordered by one of the fields.
So the task becomes to change THAT field value for one or more rows, then
have the value change in the datagrid saved to the database.

So it sounds like you are saying:

Row ID Animal
1 1 Dog
2 2 Cat
3 3 Bird
etc.

Assuming you sort on ID. Let's say you want the Cat to be Row 1, so you have
to change the ID field value of Dog and the ID value of Cat to 1. But can
you really do so? That ID will likely either be a foreign key or a primary
key. If it's an autogenerated PK, then you cannot change it at all. If it's
a FK, then you have to change the value in the related table -- again,
likely not an easy task to assure you would get the result you are looking
for. Thus it appears that the only solution would be to create a "display
priority" field where the user assigns the priority of the record in the
datagrid and then saves all the records back to the database after
"priority" changes are made.

"C. Vidal" <cvidal_nospam@univer-com.com> wrote in message
news:OI5bqmi0EHA.2804@TK2MSFTNGP15.phx.gbl...
> Hi,
>
> I have a datagrid with some columns which is binfind to a dataset.
> I would like the users can move the rows as they want in the datagrid and
> save this change in the database.
> How can i do this?
> I may be find a solution to move records in the datagrid but i don't know
> how save the order in the database.
>
> (in the table, I have a field which contains the begin order)
>
> Thanks in adavance.
>
> C. Vidal
>
> PS : sorry for my bad english
>



Relevant Pages

  • RE: sorting techniques
    ... As for how to set the DataGrid Columns' SortExpression, ... contains the data retrieved from database. ... datagrid's sort event fired, we retrieved the DataTable again(from Session ... That' s why we set the DataTable's columns's name as their sortexpression. ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)
  • Why Does Sorting Require Another Call To The Database?
    ... a datagrid from a recordset I get from the database, ... back to the database and get the recordset again every time I sort by ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)
  • Re: DataGrid Sort Problem
    ... Studio 2003.As it is only a protoype application, my database has been ... I want my sort order to be done by ResourceID, ... string it will do it alphabetically. ... the data into the DataGrid, it will be stored as numbers, not Days. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Data Grid Sort Problem
    ... Do you also have a date associated with the day, if so use this to sort on, ... Studio 2003.As it is only a protoype application, my database has been ... Basically, I am showing all Timesheet Entries in a DataGrid, by ... string it will do it alphabetically. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Primary Key not sorted
    ... Are you willing to rely on any "natural" sort of records? ... > though the Company field is the Primary Key but if I ... When I Compact and Repair the database it ...
    (microsoft.public.access.tablesdbdesign)