Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2008
    Location
    Denver, CO
    Posts
    44

    Unanswered: SQL and ASP.NET -> HTML OUTPUT

    Hi folks,

    I am having a problem and I was wondering if or what the solution is. I am using ASP.NET to get data from a database and then display it on a web page using the GridView control. I have one column that concatenates together the values from several table columns. I would like to have the output displayed with html formatting where I can add breaks between some of the lines.

    The column holds address info for people in the database. It combines the data from the address1, address2, city, state, and zipcode columns into one column. I would like there to be breaks between address1 and address2 and between address2 and city. Does anyone know if it is possible to write this into the SELECT statement directly? This is what the Address column looks like in the SELECT statement:

    SELECT ..., (adr.Street1 + ' ' + ISNULL(adr.Street2, ' ') + ' ' + adr.City + ' ' + adr.State + ', ' + adr.Zipcode) as Address, ... FROM ...;

    Right now I just have spaces between adr.Street1 and adr.Street2 and adr.Street2 and adr.City. Any help would be greatly appreciated.

    Paul
    Paul Palubinski

  2. #2
    Join Date
    Mar 2007
    Location
    Holmestrand, Norway
    Posts
    332
    Hi

    If you tried, you would see that it's quite possible. However, from a design perspective I do not like it, as you partially move presentation into the SQL Server. In my opinion, this kind of formatting should reside in ASP.NET, and not in SQL Server.
    Ole Kristian Velstadbråten Bangås - Virinco - MSSQL.no - Facebook - Twitter

  3. #3
    Join Date
    Oct 2008
    Location
    Denver, CO
    Posts
    44
    Thank you for the response. I don't mean to be rude, but I have tried and was unsuccessful and that is why I'm posting on here with the hope that someone who knows this stuff can help me out.

    I understand the importance of clearly delineating between presentation and logic, but the only other way I can see doing it in ASP would be to use a row databound event to format the cells that are generated with the gridview control, and I think that would require a lot more work than just specifying the html tags in the SQL select statement, if it is even possible...
    Paul Palubinski

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •