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.0Stored procedure sorting problemStored procedure sorting problem
Previous
 
Next
New Post
2/1/2007 7:35 PM
 
Hi,
    I am displaying data retrieved from my module database within a gridview control. I would like to be able to sort the data to view by a selected column. I think I have to amend my getlist stored procedure to do this but cannot get it to work. I have tried writing the stored procedure to accept a variable "@sort int" and then adding an "order by @sort" clause at the end of the procedure but this does not work.Can anyone tell me what I am doing wrong?

Thanks,
Phil
 
New Post
2/1/2007 8:59 PM
 
Can you show us the stored procedure and the code you're using to call it?


Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
New Post
2/2/2007 9:30 PM
 
Thanks for the reply. The stored procedure I have written is:

ALTER PROCEDURE PortfolioListSelect
AS
BEGIN
    SELECT
        ID AS ItemId,
        UserID,
        UserName,
        Email,
        Homepage,
        Image1,
        Image1Link,
        Image1Detail,
        Image2,
        Image2Link,
        Image2Detail,
        Image3,
        Image3Link,
        Image3Detail,
        Image4,
        Image4Link,
        Image4Detail,
        Image5,
        Image5Link,
        Image5Detail,
        Image6,
        Image6Link,
        Image6Detail,
        Image7,
        Image7Link,
        Image7Detail,
        Image8,
        Image8Link,
        Image8Detail,
        Image9,
        Image9Link,
        Image9Detail,
        Image10,
        Image10Link,
        Image10Detail,
        UserSkills,
        UserPosRatings,
        UserNegRatings        
    FROM [Portfolio]
END

How would I modify this procedure so I can order the data by a selected column in the gridview and what other code would I need to include?

Thanks,
Phil
 
New Post
2/3/2007 4:24 AM
 

Well you need to sort by a column not a value.

If you want to go that way you will need to make a dynamic query and execute it. If you want to do that in your stored procedure you will have to do it (package your query) as one big string which has at the end your order by clause - last line:

set @myquery = @myquery + ' order by ' + @orderbycolumn + ' asc'

and the execute it:

sp_executeSql @myquery

 


Thanks,
Vladan Strigo
NETMedia

My website: Vladan.Strigo.NET

Vladan.Strigo.NET: Projects
* Advanced VS2005 development approach - BlankModule
* DNN & Microsoft Ajax best practices guidance

Vladan.Strigo.NET: Resources
* Comprehensive list of DNN 4 Module development resources

 
New Post
2/3/2007 10:31 AM
 


Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Stored procedure sorting problemStored procedure sorting problem


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