Formatting Query Results

Last Post 15 Oct 2007 03:55 PM by cmd17. 2 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
cmd17
New Member
New Member

--
15 Oct 2007 01:20 PM
I'm building a database-driven web store using ASP.NET 2.0/VB.NET and SQL Server 2005, and I have a user control that displays a list of product categories. The control makes use of a DataList and a method that calls a stored procedure. Each category in the list is hyperlinked to another page that displays a list of products in the chosen category.

Here's the problem:

I have no trouble executing the stored procedure to display the categories. However, some category names contain more than one word, and this results in my URLs* having spaces between words:

mywebstore.com/category.aspx?id=5&name=india pale ale

What I want is for the links to look like this:

mywebstore.com/category.aspx?id=5&name=india-pale-ale

I've tried formatting the URLs on the ASP.NET side, but I haven't had any luck, so I thought that maybe the category names could be formatted in the stored procedure so that they're already in the correct format by the time they're rendered on the .aspx pages.

Any help would be greatly appreciated. Thanks in advance.

* I purposely left out the "http://www." so that these fictitious links would not be converted to live URLs.
nosepicker
New Member
New Member

--
15 Oct 2007 03:04 PM
Good thing madhivanian on sqlteam isn't answering this thread . Anyway, even though this kind of formatting should really be done outside the database, here's one thing you can do in your stored proc to change spaces to hyphens:

REPLACE(name, ' ', '-')

cmd17
New Member
New Member

--
15 Oct 2007 03:55 PM
Thank you for the quick reply. I apologize for the double post.
You are not authorized to post a reply.

Acceptable Use Policy