System.FormatException:输入字符串的十进制格式不正确

时间:2014-10-08 15:35:46

标签: c# sharepoint type-conversion decimal

将sharepoint列表项值转换为小数,并使用telerik将其分配给辐射值。辐射值是小数,在转换列表项时会发生错误。

 RadRating1.Value = Convert.ToDecimal(oList["Average Rating"]);

我也尝试过(十进制),但这会产生另一条错误消息。 关于它为什么不接受声明的任何想法?

oList人口:

void loadSuggestions() 
{
        SPList olstSuggestions = oWeb.Lists["Suggestions"];
        SPQuery qSuggestions = new SPQuery();
        qSuggestions.RowLimit.Equals(10);
        qSuggestions.Query = string.Format(@"
        <Where>
                <Eq>
                <FieldRef Name='Archived' />
                <Value Type='Choice'>No</Value>
            </Eq>
        </Where>");

        SPListItemCollection oSuggestionCollection = olstSuggestions.GetItems(qSuggestions);
        int count = 1;
        foreach (SPListItem oList in oSuggestionCollection)
        {<above statement>...}
}

1 个答案:

答案 0 :(得分:0)

请尝试以下方法:

 Convert.ToDecimal(oList["Average Rating"], new NumberFormatInfo() { NumberDecimalSeparator = "." });