2010.2.809.35 VS2008 / IE8
In the grid if I use this for GridBoundColumn it displays fine, but if my value is blank, I would like the cell to display balnk value instead of a single $ sign. Help?
DataFormatString="${0:$###,###.##}"
In the grid if I use this for GridBoundColumn it displays fine, but if my value is blank, I would like the cell to display balnk value instead of a single $ sign. Help?
DataFormatString="${0:$###,###.##}"
12 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 01 Sep 2010, 05:56 AM
Hello Lenny,
Try the following DataFormatString and see whether it helps.
DataFormatString="{0:$#.#;$(#.#);''}"
-Shinu.
Try the following DataFormatString and see whether it helps.
DataFormatString="{0:$#.#;$(#.#);''}"
-Shinu.
0
Lenny_shp
Top achievements
Rank 2
answered on 01 Sep 2010, 02:18 PM
I don't get the $ prefix when a value exists with your format string.
Basically that $ inside the format doesn't get used...
"${0:$###,###.##}" = "${0:###,###.##}"
For now I got rid of the use of DataFormatString and used FormatCurrency function in the backend to create the exact string to display in grid.
Basically that $ inside the format doesn't get used...
"${0:$###,###.##}" = "${0:###,###.##}"
For now I got rid of the use of DataFormatString and used FormatCurrency function in the backend to create the exact string to display in grid.
0
Hello Lenny_shp,
Could you please try using the following dataformatstring and let me know if the issue still persists:
Regards,
Radoslav
the Telerik team
Could you please try using the following dataformatstring and let me know if the issue still persists:
<telerik:GridBoundColumn DataField="Money" DataFormatString="{0:C}" HeaderText="Money"> </telerik:GridBoundColumn>Regards,
Radoslav
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Lenny_shp
Top achievements
Rank 2
answered on 07 Sep 2010, 04:28 PM
DataFormatString="{0:C}" doesn't display a $ prefix.
0
Hi Lenny_shp,
You could try setting the Page.Culture property to en-US this will force the $ sing to be showed. I am sending you a simple example which demonstrates this approach.
Also you could achieve the desired functionality with writing the following code snippet:
I hope this helps.
All the best,
Radoslav
the Telerik team
You could try setting the Page.Culture property to en-US this will force the $ sing to be showed. I am sending you a simple example which demonstrates this approach.
Also you could achieve the desired functionality with writing the following code snippet:
void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e){ if (e.Item is GridDataItem) { GridDataItem item = e.Item as GridDataItem; if (item["ColumnUniqueName"].Text == "$") { item["ColumnUniqueName "].Text = ""; } }}I hope this helps.
All the best,
Radoslav
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Lenny_shp
Top achievements
Rank 2
answered on 10 Sep 2010, 02:30 PM
I tested with Culture="en-US" but it didn't show $.
My grid's data source is XML from NeedDataSource.
Dim ds As DataSet = New DataSet
Dim xmlSR As System.IO.StringReader = Nothing
Dim xmlDocWriter As New XmlDocument
Dim xmlWriterObj As XmlWriter = xmlDocWriter.CreateNavigator().AppendChild
....
xmlWriterObj.WriteAttributeString("Units", myObject.Units)
.....
ds.ReadXml(xmlSR)
RadGrid1.DataSource = ds
<telerik:GridBoundColumn HeaderText="Units" UniqueName="Units" DataField="Units" ReadOnly="true" DataFormatString="{0:C}">
<HeaderStyle HorizontalAlign="Right" />
<ItemStyle HorizontalAlign="Right" />
</telerik:GridBoundColumn>
My grid's data source is XML from NeedDataSource.
Dim ds As DataSet = New DataSet
Dim xmlSR As System.IO.StringReader = Nothing
Dim xmlDocWriter As New XmlDocument
Dim xmlWriterObj As XmlWriter = xmlDocWriter.CreateNavigator().AppendChild
....
xmlWriterObj.WriteAttributeString("Units", myObject.Units)
.....
ds.ReadXml(xmlSR)
RadGrid1.DataSource = ds
<telerik:GridBoundColumn HeaderText="Units" UniqueName="Units" DataField="Units" ReadOnly="true" DataFormatString="{0:C}">
<HeaderStyle HorizontalAlign="Right" />
<ItemStyle HorizontalAlign="Right" />
</telerik:GridBoundColumn>
0
Hi Lenny_shp,
When you bind the RadGrid to a xml file, all data from it has String as a type. So when you set the DataFormatString="{0:C}" to the column it could not format the value, because the value is not a Double. To achieve the desired functionality you need to parse the string values to the appropriate type into RadGrid.ItemDataBound:
Additionally I am sending you a simple example which demonstrates the desired functionality.
I hope this helps.
Sincerely yours,
Radoslav
the Telerik team
When you bind the RadGrid to a xml file, all data from it has String as a type. So when you set the DataFormatString="{0:C}" to the column it could not format the value, because the value is not a Double. To achieve the desired functionality you need to parse the string values to the appropriate type into RadGrid.ItemDataBound:
Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound If TypeOf e.Item Is GridDataItem Then Dim item As GridDataItem = TryCast(e.Item, GridDataItem) Dim value As Double If [Double].TryParse(item("money").Text, value) Then item("money").Text = value.ToString("C") End If End If End SubAdditionally I am sending you a simple example which demonstrates the desired functionality.
I hope this helps.
Sincerely yours,
Radoslav
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Asutosh
Top achievements
Rank 1
answered on 20 Jun 2014, 06:04 AM
hi
i am using radgrid view
in that there is one currency column
i use DataFormatString="{0:C}" to format that its works fine for positive value but for negative its give round bracket
ex: if value is -10 then out put show ($10)
i want -$10 in rad grid if input is -10
help me
i am using radgrid view
in that there is one currency column
i use DataFormatString="{0:C}" to format that its works fine for positive value but for negative its give round bracket
ex: if value is -10 then out put show ($10)
i want -$10 in rad grid if input is -10
help me
0
Princy
Top achievements
Rank 2
answered on 20 Jun 2014, 10:23 AM
Hi Asutosh,
You can try the following code snippet to have the currency format for negative numbers.
C#:
Thanks,
Princy
You can try the following code snippet to have the currency format for negative numbers.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e){ if (e.Item is GridDataItem) { GridDataItem dataItem = (GridDataItem)e.Item; System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en-US"); culture.NumberFormat.CurrencyNegativePattern = 1; double value =Convert.ToDouble( dataItem["ColumnUniqueName"].Text); dataItem["ColumnUniqueName"].Text = value.ToString("C", culture); }}Thanks,
Princy
0
Asutosh
Top achievements
Rank 1
answered on 21 Jun 2014, 08:48 AM
thanks for your reply
bt in this i ddnt get any value in dataItem
so it give me error
my code is as below
protected void grd_firstchart_aco_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem dataItem = (GridDataItem)e.Item;
System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en-US");
culture.NumberFormat.CurrencyNegativePattern = 1;
double value = Convert.ToDouble(dataItem["AvgSavings"].Text);
dataItem["AvgSavings"].Text = value.ToString("C", culture);
}
}
bt in this i ddnt get any value in dataItem
so it give me error
my code is as below
protected void grd_firstchart_aco_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem dataItem = (GridDataItem)e.Item;
System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en-US");
culture.NumberFormat.CurrencyNegativePattern = 1;
double value = Convert.ToDouble(dataItem["AvgSavings"].Text);
dataItem["AvgSavings"].Text = value.ToString("C", culture);
}
}
0
Princy
Top achievements
Rank 2
answered on 21 Jun 2014, 09:07 AM
Hi Asutosh,
Im not clear about your issue, can you provide your ASPX code snippet as well. With below code I was able to get it working, check the attached screenshot.
ASPX:
C#:
Thanks,
Princy
Im not clear about your issue, can you provide your ASPX code snippet as well. With below code I was able to get it working, check the attached screenshot.
ASPX:
<telerik:GridBoundColumn DataField="Freight" HeaderText="Freight" UniqueName="Freight" />C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e){ if (e.Item is GridDataItem) { GridDataItem dataItem = (GridDataItem)e.Item; System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en-US"); culture.NumberFormat.CurrencyNegativePattern = 1; double value = Convert.ToDouble(dataItem["Freight"].Text); dataItem["Freight"].Text = value.ToString("C", culture); }}Thanks,
Princy
0
Asutosh
Top achievements
Rank 1
answered on 22 Jul 2014, 06:36 AM
hi princy
i am using radhtml chart
i have tool tip also in radhtml chart
now in tool tip i have currency data
when it comes in negative it will show round bracket out side
ex : data = -500
output = ($500)
i want out put -$500
i am using below code to tool tip formating
#= kendo.format(\\\'{0:C\\\',dataItem." + displaydata)#";
i am using radhtml chart
i have tool tip also in radhtml chart
now in tool tip i have currency data
when it comes in negative it will show round bracket out side
ex : data = -500
output = ($500)
i want out put -$500
i am using below code to tool tip formating
#= kendo.format(\\\'{0:C\\\',dataItem." + displaydata)#";
