ratkinso666
asked on
Reorder Items in sql database
Hi all, looking for some help on re-ordering. I have a parent with several siblings, the siblings are ordered by a display_order field. I need to be able to drop a NEW sibling in the middle and re-order the siblings accordingly... I am thinking about making the display_order field go by 10's or 100's, and drop a new one in the middle, but I really don't like this solution and it would eventually fill up anyway. I'm sure there is some GREAT code out there to help out with this, or at least some ideas on how to go about it. I am doing this in Visual Studio 2005 VB.net. They are adding the siblings in via a detailsview grid.
Thanks,
Randy
Thanks,
Randy
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sounds like a great idea, I like it. Would I somehow do that in the ItemInserting section??
Yes,
argNewSibling would be an object (or a number, or a string, ...) representing the new sibling; and argBeforeSibling (or argAfterSibling) would be the desired neighbour for the new sibling. Remember, if you've inserted the items as numbers, then you need to refer to numbers when you compare (and likewise, if you inserted strings, you need to compare against strings).
I hope that makes sense.
argNewSibling would be an object (or a number, or a string, ...) representing the new sibling; and argBeforeSibling (or argAfterSibling) would be the desired neighbour for the new sibling. Remember, if you've inserted the items as numbers, then you need to refer to numbers when you compare (and likewise, if you inserted strings, you need to compare against strings).
I hope that makes sense.
ASKER
coming along nicely, but what is the syntax to pass more than one value from the gridview to the detailsview?? I have two parameters (in the datakey names) in the gridview BA_ID, BA_DispOrder. I need the BA_ID to pass to my next gridview and since it is my primary I have no problem using it, but I need the BA_DispOrder to know my selection from the gridview, after I get this last part I will be finished with this. This is what I am trying to use in my Insert Parameters section:
<asp:ControlParameter ControlID="GridView2" Name="BA_DispOrder" PropertyName="SelectedValu e"
Type="Int32" />
I need it as my value, this works for the first parameter in a list, but I guess not for the secondary one??
Thanks,
Randy
<asp:ControlParameter ControlID="GridView2" Name="BA_DispOrder" PropertyName="SelectedValu
Type="Int32" />
I need it as my value, this works for the first parameter in a list, but I guess not for the secondary one??
Thanks,
Randy
ASKER
I know in the code behind I would get it like this:
Dim NewOrder As String = (GridView2.SelectedDataKey .Values("B A_DispOrde r").ToStri ng())
so, I could run an update on this in the code behind, after I do my insert, but I would rather do it on the insert from the detailsview...
Dim NewOrder As String = (GridView2.SelectedDataKey
so, I could run an update on this in the code behind, after I do my insert, but I would rather do it on the insert from the detailsview...
ASKER
Thank you for the excellent help!!!
This would still require that you are able to identify the next (or previous) sibling when you're about to insert the new sibling
For example:
Private colSiblings As New Collection
Then you can insert a new sibling relative to its adjacent sibling, for example:
colSiblings.Add(argNewSibl
or
colSiblings.Add(argNewSibl