Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Little help reordering items in Stored ProcLittle help reordering items in Stored Proc
Previous
 
Next
New Post
1/17/2007 3:40 PM
 

I looked at the way this was done with tabs but that seems like a lot of code and I thought a stored proc might be easier can anybody help me polish this off

I have a table

ID SortOrder Question
1 4 Question 1
2 1 Question 2
3 2 Question 3

I query the table and sort by the sortorder - I get

Question 2

Question 3

Question 1

-Now I have requirement to be able to reorder the questions so I created a stored proc to do that part

Okay so in this case I find the ID of the question that would have a sortorder lower than the QuestionID i send to the proc

the first problem is if I send an id that has a sortorder of 1 it redoes it to 0 then goes on to -1 - how can i stop that

Is there a better way to do it?

PROCEDURE [dbo].[RCI_CAP_ReorderQuestions]
 @QuestionID int,
 @CompanyID int,
 @Move bit
AS
BEGIN
 -- SET NOCOUNT ON added to prevent extra result sets from
 -- interfering with SELECT statements.
 SET NOCOUNT ON;

 --This is the id of the question to change to
 DECLARE @IDUpper int
    -- Insert statements for procedure here
 IF @Move=1 --Move item higher in list (subtract from position)
  BEGIN
   SELECT @IDUpper= ID
   FROM RCI_CAP_CapQuestions
   Where CompanyID = @CompanyID
    AND QuestionOrder+1 =
    (SELECT QuestionOrder
     FROM RCI_CAP_CapQuestions
     WHERE ID = @QuestionID)

   UPDATE RCI_CAP_CapQuestions
   SET QuestionOrder=QuestionOrder+1
   Where ID = @IDUpper

   UPDATE RCI_CAP_CapQuestions
   SET QuestionOrder=QuestionOrder-1
   Where ID = @QuestionID

 

   
  END
END


Dylan Barber http://www.braindice.com - Dotnetnuke development classes - skins and modules
 
New Post
1/17/2007 4:10 PM
 
what do you want to do exactly - sort by sort order, exchange the order of two items or make the order numbers consecutive?

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
1/17/2007 4:34 PM
 

Well I can already sort by the QuestionOrder (I called it sortorder) but what I really want to do is exchange positions (sortorders)  with two rows

I sort of have it in the stored proc i posted above but it has a problem in that if the QuestionOrder is 1 or lower it keeps subtracting is there a way to check this a little more or should I be doing this in the asp.net page maybe


Dylan Barber http://www.braindice.com - Dotnetnuke development classes - skins and modules
 
New Post
1/17/2007 4:39 PM
 

maybe you should just have a look into the source/sprocs of UDT module ;-)


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
1/17/2007 4:49 PM
 
Okay i'll do that I have never worked that much with that module so didnt know it even did anyhting like that

Dylan Barber http://www.braindice.com - Dotnetnuke development classes - skins and modules
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Little help reordering items in Stored ProcLittle help reordering items in Stored Proc


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out