Asp.net 从代码隐藏设置GridTemplateColumn DataBinder.Eval(Container.DataItem)的货币
请参见Asp.net 从代码隐藏设置GridTemplateColumn DataBinder.Eval(Container.DataItem)的货币,asp.net,.net,telerik-grid,currency,Asp.net,.net,Telerik Grid,Currency,请参见ASPX页面上的以下RadGrid代码: <telerik:GridTemplateColumn DataField="Supplier_Price" Aggregate="Sum" FooterText="Unit Price: " FilterControlAltText="Filter Supplier_Price column" HeaderText="Unit Price" SortExpression="Supplier_Price" UniqueName="Suppli
ASPX
页面上的以下RadGrid代码:
<telerik:GridTemplateColumn DataField="Supplier_Price" Aggregate="Sum" FooterText="Unit Price: " FilterControlAltText="Filter Supplier_Price column" HeaderText="Unit Price" SortExpression="Supplier_Price" UniqueName="Supplier_Price" DataType="System.Double" FooterAggregateFormatString="{0:c}">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "Supplier_Price", "{0:C}")%>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadNumericTextBox runat="server" ID="SupplierPriceRadNumericTextBox" Culture="ar-SA" MinValue="0" MaxValue="9999999999" Text='<%#Bind ("Supplier_Price") %>' Type="Currency" NumberFormat-DecimalSeparator="," NumberFormat-AllowRounding="true" NumberFormat-DecimalDigits="2">
<NumberFormat DecimalDigits="2" DecimalSeparator="." />
</telerik:RadNumericTextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
现在我的问题是,我需要将上面列中的
{0:C}
的货币区域性从“代码隐藏”更改为
<telerik:GridNumericColumn DataField="Supplier_Price" Aggregate="Sum" FooterText="Unit Price: " FilterControlAltText="Filter Supplier_Price column" HeaderText="Unit Price" SortExpression="Supplier_Price" UniqueName="Supplier_Price" DataType="System.Double" FooterAggregateFormatString="{0:c}">
</telerik:GridNumericColumn>
SelectCurrencyDropDownList.SelectedItem.Value==“JPY”
基本上是一个dropdownlist
,用户在其中选择货币,OnPreRender
启动,一切正常
protected void SupplierPriceRadGrid_PreRender(object sender, EventArgs e)
{
foreach (GridColumn column in SupplierPriceRadGrid.Columns)
{
if (SelectCurrencyDropDownList.SelectedItem.Value == "SAR")
{
if (column.UniqueName == "Supplier_Price")
{
(column as GridNumericColumn).DataFormatString = "{0:N2} .ر.س";
(column as GridNumericColumn).FooterAggregateFormatString = "{0:N2} .ر.س";
}
if (column.UniqueName == "Supplier_Total_Price")
{
(column as GridNumericColumn).DataFormatString = "{0:N2} .ر.س";
(column as GridNumericColumn).FooterAggregateFormatString = "{0:N2} .ر.س";
}
}
if (SelectCurrencyDropDownList.SelectedItem.Value == "USD")
{
if (column.UniqueName == "Supplier_Price")
{
(column as GridNumericColumn).DataFormatString = "$ {0:N2}";
(column as GridNumericColumn).FooterAggregateFormatString = "$ {0:N2}";
}
if (column.UniqueName == "Supplier_Total_Price")
{
(column as GridNumericColumn).DataFormatString = "$ {0:N2}";
(column as GridNumericColumn).FooterAggregateFormatString = "$ {0:N2}";
}
}
if (SelectCurrencyDropDownList.SelectedItem.Value == "EUR")
{
if (column.UniqueName == "Supplier_Price")
{
(column as GridNumericColumn).DataFormatString = "€ {0:N2}";
(column as GridNumericColumn).FooterAggregateFormatString = "€ {0:N2}";
}
if (column.UniqueName == "Supplier_Total_Price")
{
(column as GridNumericColumn).DataFormatString = "€ {0:N2}";
(column as GridNumericColumn).FooterAggregateFormatString = "€ {0:N2}";
}
}
if (SelectCurrencyDropDownList.SelectedItem.Value == "GBP")
{
if (column.UniqueName == "Supplier_Price")
{
(column as GridNumericColumn).DataFormatString = "£ {0:N2}";
(column as GridNumericColumn).FooterAggregateFormatString = "£ {0:N2}";
}
if (column.UniqueName == "Supplier_Total_Price")
{
(column as GridNumericColumn).DataFormatString = "£ {0:N2}";
(column as GridNumericColumn).FooterAggregateFormatString = "£ {0:N2}";
}
}
if (SelectCurrencyDropDownList.SelectedItem.Value == "CNY")
{
if (column.UniqueName == "Supplier_Price")
{
(column as GridNumericColumn).DataFormatString = "元 {0:N2}";
(column as GridNumericColumn).FooterAggregateFormatString = "元 {0:N2}";
}
if (column.UniqueName == "Supplier_Total_Price")
{
(column as GridNumericColumn).DataFormatString = "元 {0:N2}";
(column as GridNumericColumn).FooterAggregateFormatString = "元 {0:N2}";
}
}
if (SelectCurrencyDropDownList.SelectedItem.Value == "JPY")
{
if (column.UniqueName == "Supplier_Price")
{
(column as GridNumericColumn).DataFormatString = "¥ {0:N2}";
(column as GridNumericColumn).FooterAggregateFormatString = "¥ {0:N2}";
}
if (column.UniqueName == "Supplier_Total_Price")
{
(column as GridNumericColumn).DataFormatString = "¥ {0:N2}";
(column as GridNumericColumn).FooterAggregateFormatString = "¥ {0:N2}";
}
}
}
}