I'm using a 3rd-party component for a shopping cart (dotnetCART), and I am having a problem formatting a string. I know that since this is a 3rd-party control, you all may not be able to help, but I thought I's ask anyways...
The dotnetCART component has a web control called "Display Catalog" which displays products from the database. Although fields such as "Price" and "Weight" are included in the web control, my "WholePrice" field is not, and so I have to pull it in using the "GetCustom" property (or is it called a method?).
Right now the code in question looks like this:
Code:
<dotnetCART:DisplayCatalog>
...code...
<ItemDetailsTemplate>
<asp:Label
ID="lblWholesalePrice"
runat="server"
Text='<%#Container.GetCustom("WholePrice") %>'>
</asp:Label>
</ItemDetailsTemplate>
</dotnetCART:DisplayCatalog>
(FYI, a non-custom field would have been written into the label as "<%#Container.Price%>")
The above label works OK, but it displays the data without formatting, and so my "WholePrice" appears as "12.55" or "6.554", not "$6.55". I've read the asp.net information on formatting strings, and I have tried to apply a similar formatting syntax to the "Container.GetCustom" without success. I have tried:
Code:
Text='<%#Container.GetCustom(FormatCurrency("WholePrice")) %>'>
...returns an error from the component: "Conversion from string "WholePrice" to type 'Double' is not valid."
Code:
Text='<%#Container.GetCustom("WholePrice","{0:c}") %>'
...returns "BC30057: Too many arguments to 'Public Function GetCustom(strField As String) As String'."
Code:
Text='<%# DataBinder.Eval(Container.GetCustom, "WholePrice", "{0:c}")%> '>
...returns "BC30455: Argument not specified for parameter 'strField' of 'Public Function GetCustom(strField As String) As String'."
and
Code:
Text='<%# String.Format("{0:c}", Container.GetCustom("WholePrice")) %>'
... does not have any effect, but displays the unformatted "WholePrice".
Once again, I realize no one may be able to help in this case, but thank you for any advice or suggestions. The 3rd-party documentation seems a little fuzzy on this subject to my novice eyes, but the relevent passages appear to be as follows:
Quote:
quote:
Display Catalog Properties:
CategoryCustomFields: List of fields from categories table that you want to show in the template using the GetCustom property.
CategoryCustomFields = "Created"
Catalog Template Properties / Containers:
GetCustom("FieldName"): Used to show custom field data in the Templates. This returns any custom field data.
Programmatically changing a control value within a given page:
This is useful if you wish to change a control within the template programmatically, for example for language customization.
Label myTemp = (Label) Page.FindControl("Catalog:ItemDetails:myWeight");
if(myTemp != null);
myTemp.Text="Weight(Test):";
The "Catalog:ItemDetails:myWeight" is the ID for Weight label control used in default.aspx. The "Catalog" is the ID control in default.aspx page for Catalog control and "ItemDetails" is hardcoded ID inside the component for ItemDetailsTemplate Template. "myWeight" is the ID for label inside the ItemDetailsTemplate Template in default.aspx page
|
Thanks again.