swap 2 rows

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

Hi-

I need to make an interface to edit Technical Data records. Table looks
like this:


Tbl_Tech_Specs
[ TSID(pk) ] [ SpecName ] [ SpecValue ]


So if there were 2 records;

2 "Voltage" "5v"
8 "Width" "11 in."

I would like the user to be able to swap the values of 8 w/ 2.
There are no other criteria for how the records are orderd, nothing logical
though. i could try to place some sort of "Order" field, but that seems
hard to manage as I would want them to be unique.
Instead I was thinking of "move up" and "move down" links that would swap
the values.

But in typing this I realized I'm not sure that I would know how to setup
the DataGrid binding to have each item also have the previous DataItems TSID
(required if I'm going to swap them)

argh... how can this be done? Is there an ADO.net class somewhere that can
handle this? Have any of you done this? If so, how did you solve it?

Thanks-
Steve
 
Hi Steve,

Steve said:
Hi-

I need to make an interface to edit Technical Data records. Table looks
like this:


Tbl_Tech_Specs
[ TSID(pk) ] [ SpecName ] [ SpecValue ]


So if there were 2 records;

2 "Voltage" "5v"
8 "Width" "11 in."

I would like the user to be able to swap the values of 8 w/ 2.
There are no other criteria for how the records are orderd, nothing logical
though. i could try to place some sort of "Order" field, but that seems
hard to manage as I would want them to be unique.
Instead I was thinking of "move up" and "move down" links that would swap
the values.

Yes, use DataView and Order field.
Why would be hard to manage it?
Just put a "global" variable somewhere that contains last order value.
 
I don't want to change the ordering of the whole DataView or Database table,
I want to swap 2 rows with each others data.
I would need to know the ID of the row above and below the row that I would
like to swap

(I think)


Miha Markic said:
Hi Steve,

Steve said:
Hi-

I need to make an interface to edit Technical Data records. Table looks
like this:


Tbl_Tech_Specs
[ TSID(pk) ] [ SpecName ] [ SpecValue ]


So if there were 2 records;

2 "Voltage" "5v"
8 "Width" "11 in."

I would like the user to be able to swap the values of 8 w/ 2.
There are no other criteria for how the records are orderd, nothing logical
though. i could try to place some sort of "Order" field, but that seems
hard to manage as I would want them to be unique.
Instead I was thinking of "move up" and "move down" links that would swap
the values.

Yes, use DataView and Order field.
Why would be hard to manage it?
Just put a "global" variable somewhere that contains last order value.
 
Hi Steve,

You'll need to find BindingManagerBase for your grid - its Current property
will give you the focused row.
For finding rows near the focused one, you might use its Position property.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Steve said:
I don't want to change the ordering of the whole DataView or Database table,
I want to swap 2 rows with each others data.
I would need to know the ID of the row above and below the row that I would
like to swap

(I think)


Miha Markic said:
Hi Steve,

Steve said:
Hi-

I need to make an interface to edit Technical Data records. Table looks
like this:


Tbl_Tech_Specs
[ TSID(pk) ] [ SpecName ] [ SpecValue ]


So if there were 2 records;

2 "Voltage" "5v"
8 "Width" "11 in."

I would like the user to be able to swap the values of 8 w/ 2.
There are no other criteria for how the records are orderd, nothing logical
though. i could try to place some sort of "Order" field, but that seems
hard to manage as I would want them to be unique.
Instead I was thinking of "move up" and "move down" links that would swap
the values.

Yes, use DataView and Order field.
Why would be hard to manage it?
Just put a "global" variable somewhere that contains last order value.
 
ah, this sounds promising.... I'll look into this some more, thanks!


Miha Markic said:
Hi Steve,

You'll need to find BindingManagerBase for your grid - its Current property
will give you the focused row.
For finding rows near the focused one, you might use its Position property.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Steve said:
I don't want to change the ordering of the whole DataView or Database table,
I want to swap 2 rows with each others data.
I would need to know the ID of the row above and below the row that I would
like to swap

(I think)


Miha Markic said:
Hi Steve,

Hi-

I need to make an interface to edit Technical Data records. Table looks
like this:


Tbl_Tech_Specs
[ TSID(pk) ] [ SpecName ] [ SpecValue ]


So if there were 2 records;

2 "Voltage" "5v"
8 "Width" "11 in."

I would like the user to be able to swap the values of 8 w/ 2.
There are no other criteria for how the records are orderd, nothing
logical
though. i could try to place some sort of "Order" field, but that seems
hard to manage as I would want them to be unique.
Instead I was thinking of "move up" and "move down" links that would swap
the values.

Yes, use DataView and Order field.
Why would be hard to manage it?
Just put a "global" variable somewhere that contains last order value.
 
It looks like this is not available for WebControls
I might have failed to mention that this is a web based application
(asp.net)


Miha Markic said:
Hi Steve,

You'll need to find BindingManagerBase for your grid - its Current property
will give you the focused row.
For finding rows near the focused one, you might use its Position property.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Steve said:
I don't want to change the ordering of the whole DataView or Database table,
I want to swap 2 rows with each others data.
I would need to know the ID of the row above and below the row that I would
like to swap

(I think)


Miha Markic said:
Hi Steve,

Hi-

I need to make an interface to edit Technical Data records. Table looks
like this:


Tbl_Tech_Specs
[ TSID(pk) ] [ SpecName ] [ SpecValue ]


So if there were 2 records;

2 "Voltage" "5v"
8 "Width" "11 in."

I would like the user to be able to swap the values of 8 w/ 2.
There are no other criteria for how the records are orderd, nothing
logical
though. i could try to place some sort of "Order" field, but that seems
hard to manage as I would want them to be unique.
Instead I was thinking of "move up" and "move down" links that would swap
the values.

Yes, use DataView and Order field.
Why would be hard to manage it?
Just put a "global" variable somewhere that contains last order value.
 
Hi Steve,

Aaaa, did you try using SelectedIndex property then?

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Steve said:
It looks like this is not available for WebControls
I might have failed to mention that this is a web based application
(asp.net)


Miha Markic said:
Hi Steve,

You'll need to find BindingManagerBase for your grid - its Current property
will give you the focused row.
For finding rows near the focused one, you might use its Position property.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Steve said:
I don't want to change the ordering of the whole DataView or Database table,
I want to swap 2 rows with each others data.
I would need to know the ID of the row above and below the row that I would
like to swap

(I think)


"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
Hi Steve,

Hi-

I need to make an interface to edit Technical Data records. Table looks
like this:


Tbl_Tech_Specs
[ TSID(pk) ] [ SpecName ] [ SpecValue ]


So if there were 2 records;

2 "Voltage" "5v"
8 "Width" "11 in."

I would like the user to be able to swap the values of 8 w/ 2.
There are no other criteria for how the records are orderd, nothing
logical
though. i could try to place some sort of "Order" field, but that seems
hard to manage as I would want them to be unique.
Instead I was thinking of "move up" and "move down" links that would
swap
the values.

Yes, use DataView and Order field.
Why would be hard to manage it?
Just put a "global" variable somewhere that contains last order value.
 
Back
Top