Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm using Umbraco 7 and the only place in my script that's getting an error is when I try to convert a string to an int or decimal.
var price = home.price.AsInt(); or int price = home.price.AsInt();
It will work fine without the AsInt() and take out all the math. There is a value in for the price for each node.
This is in a partial view macro.
Hello, what is the definition of "home"?
@helper displayHomes(dynamic homes) { if (homes.Any()) { foreach (var home in homes.OrderBy("price")) { var price = home.price.AsInt();
Ok, as it's dynamic you will need to cast it, e.g.
string priceString = (string)CurrentPage.price; int price = priceString.AsInt();
Are you sure that price isn't already a int, then you could cast it directly, e.g.
int price = (int)CurrentPage.price;
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Converting strings to int or decimals
I'm using Umbraco 7 and the only place in my script that's getting an error is when I try to convert a string to an int or decimal.
var price = home.price.AsInt(); or int price = home.price.AsInt();
It will work fine without the AsInt() and take out all the math. There is a value in for the price for each node.
This is in a partial view macro.
Hello, what is the definition of "home"?
@helper displayHomes(dynamic homes) { if (homes.Any()) { foreach (var home in homes.OrderBy("price")) {
var price = home.price.AsInt();
Ok, as it's dynamic you will need to cast it, e.g.
Are you sure that price isn't already a int, then you could cast it directly, e.g.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.