Results 1 to 9 of 9

Thread: [RESOLVED] ASP:Hyerlinkfield with Whitespace

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2003
    Location
    Newark-on-trent, Nottingham
    Posts
    243

    Resolved [RESOLVED] ASP:Hyerlinkfield with Whitespace

    Code:
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:FixedLineProvisioningConnectionString %>"
            SelectCommand="SELECT trim(tblFixedLine_order_summary.bid_model) FROM tblFixedLine_order_summary WHERE (tblFixedLine_order_summary.fllog_ref = @fllog_ref)">
    I'm getting 'trim' is not a recognized built-in function name.

    I need to trim it as when i display the data from tblFixedLine_order_summary.bid_model in my detailsview its a hyperlink to the file and the link doesnt work becuase of trailing %20's.

    Thanks in advance for your help and advice.

    Steve

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: ASP:Hyerlinkfield with Whitespace

    Hey,

    Have you verified that the query works correctly against the database, before you try to run it through the SqlDataSource? i.e. can you put it into Enterprise Manager, or Query Analyzer to verify that it is valid?

    Gary

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2003
    Location
    Newark-on-trent, Nottingham
    Posts
    243

    Re: ASP:Hyerlinkfield with Whitespace

    The link comes out correctly in the hyperlink field except for the fact it has several %20%20%20 where the whitespace is in the Database.

    I believe the whitespace is caused by the field being an nchar(20) but i do not have schema access to the database merely the ability to pull data from it.

  4. #4
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Re: ASP:Hyerlinkfield with Whitespace

    Have you tried:

    1. Retrieve the data then use substring to cut the text that starts with that &#37; sign.
    2. Retrieve the data as toString().trim(), <= not sure if this could work

  5. #5
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: ASP:Hyerlinkfield with Whitespace

    try RTRIM - right trim spaces.

    Code:
    SELECT Rtrim(tblFixedLine.............

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: ASP:Hyerlinkfield with Whitespace

    Hey,

    The if above doesn't work, then you may need to handle the population of the hyperlinkfield in the code behind, rather than directly in the aspx. That way, you will be able to have full control over the string, and can format it however you want.

    Gary

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Oct 2003
    Location
    Newark-on-trent, Nottingham
    Posts
    243

    Re: ASP:Hyerlinkfield with Whitespace

    When i use rtrim i get the error "A field or property with the name 'bid_model' was not found on the selected data source."

    So it looks like i need to setup the hyperlink field in the VB code behind as gep13 suggested... any ideas where to start?

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Oct 2003
    Location
    Newark-on-trent, Nottingham
    Posts
    243

    Re: ASP:Hyerlinkfield with Whitespace

    I chanced across the answer if anyone ever has the same difficulties i used:

    LTrim(RTrim(tblFixedLine_order_summary.bid_model))AS bid_model

    Thanks all for your suggestions!

  9. #9
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED] ASP:Hyerlinkfield with Whitespace

    You could just URLDecode it instead, but did you mean that there are &#37;20s at the end of the URL?

Posting Permissions

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



Click Here to Expand Forum to Full Width