Configuration Question

Last post 08-22-2006 2:54 AM by scokim. 6 replies.

Sort Posts:

  • Configuration Question

    06-20-2006, 6:57 PM
    • Member
      15 point Member
    • robin302
    • Member since 06-20-2006, 10:36 PM
    • Posts 3
    When a user completes an ad form, he is required to put a price in the textbox. Does someone know how I can I can change that requirement to an option? I would also like to change it to accept a text value such as "Best Offer" instead of a numerical value. Any help would be greatly appreciated.
  • Re: Configuration Question

    06-23-2006, 8:01 PM
    • Member
      405 point Member
    • marcgel
    • Member since 02-14-2003, 10:33 PM
    • Seattle
    • Posts 76

    In the Ads table in the db, the Price field does not allow nulls. There is logic (in the displaying of ads and searching by price) that depends on price not being null. It could be modified, but could be a bit of work. Maybe the minimal amount of work would be to add a checkbox field "or best offer" and then you can display that easily in Search page results. Your changes then are just additive.

    [This posting is provided "AS IS" with no warranties, and confers no rights.]
  • Re: Configuration Question

    06-24-2006, 9:02 PM
    • Member
      15 point Member
    • robin302
    • Member since 06-20-2006, 10:36 PM
    • Posts 3
    Thanks Marcgel. I was hoping it would be something simple but after trying serveral different things to get it to work, all I did was get errors. I really appreciate your response. I'll see what I can do with your suggestion.
  • Re: Configuration Question

    08-20-2006, 2:32 AM
    • Contributor
      3,017 point Contributor
    • paggy4u
    • Member since 05-19-2004, 7:29 AM
    • Posts 774
    robin302:
    Thanks Marcgel. I was hoping it would be something simple but after trying serveral different things to get it to work, all I did was get errors. I really appreciate your response. I'll see what I can do with your suggestion.



    --------------------------------------------------
    Hello Robin302,

    Have you found a solution for this. I am also interested in the solution. Pl. guide if you alraedy ahve solved this.

    Thanks
    Paggy4u
    -----------------------------------------
    Working with Dynamic Languages
  • Re: Configuration Question

    08-21-2006, 2:22 PM
    • Member
      328 point Member
    • himawari
    • Member since 07-19-2006, 7:26 PM
    • Vancouver, BC
    • Posts 63

    My client wants to have an option to hide as he see fits.  I worked around the problem to treat $0 as the special case, in which I would display a custom message instead of the price.

    First, I declare a constant in the Search.cs

    protected const string CALL_MESSAGE = "CALL";

    Then I add the two functions within the class:

    protected string PriceToString(object price) {
       
    return PriceToString(Convert.ToInt32(price));
    }

    protected string PriceToString(int price) {
       
    return (price > 0) ? string.Format("{0:C2}", price) : CALL_MESSAGE;
    }

    In the showad.cs, I modify the AdDetails_ItemDataBound function to display the custom message:

    protected

    void AdDetails_ItemDataBound(object sender, RepeaterItemEventArgs e) {
       ...
       if (ad != null) { 
          ...
          AdPriceLabel.Text = (ad.Price > 0) ? String.Format("{0:c}", ad.Price) : CALL_MESSAGE;
          ...
       }
       ...
    }

    In search.aspx, I Changed the itemtemplate in the datagrid to

    ...
    <
    asp:TemplateField HeaderText="Price" SortExpression="Price">
       
    <ItemTemplate><%# PriceToString(Eval("Price")) %></ItemTemplate>
    ...

    Finally, you may also want to  change the label in the PostAd.aspx from price to something like "Price: (0 for CALL)", etc.

    My solution is pretty much a hack. You may be able to find better solutions with similar idea. Please let me know if it works out for you.

  • Re: Configuration Question

    08-21-2006, 11:14 PM
    • Contributor
      3,017 point Contributor
    • paggy4u
    • Member since 05-19-2004, 7:29 AM
    • Posts 774
    Dear Himawari,

    I just need a simple solution, perhaps more simpler than you mentioned above. I just need to remove the
    $ Sign in price. So that it can be used in any country. I do not want any sign, not even Rupees or Pounds etc.

    Everything else is  ok. I know a bit to make the changes like String.Format("{0:c}",
    but i am not too sure where to make changes, anmd what to place there, and on which pages.
    Can you guide me please.

    Thanks

    Paggy4u
    -----------------------------------------
    Working with Dynamic Languages
  • Re: Configuration Question

    08-22-2006, 2:54 AM
    • Member
      185 point Member
    • scokim
    • Member since 06-07-2006, 8:26 AM
    • Posts 47
    To remove the $ sign in Price, I think there are few places to change :

    1) classifiedsdb.mdf : Open the Ads Table Definition and change the Price datatype from 'money' to 'int'

    2) showad.aspx.vb : Change the format of 'AdPriceLabel.Text' to AdPriceLabel.Text = String.Format("{0}", ad.Price
    <<sorry i'm not using C# but you should be able to find it in the code behind page of showad.aspx in C#>>

    3) search.aspx :  remove the $ from DataFormatString in
     <asp:BoundField HeaderText="Price" DataField="Price" SortExpression="Price" DataFormatString="$ {0:F0}" HtmlEncode="False">

Page 1 of 1 (7 items)