Whatever I do (and I've tried many ideas already given in these forums) i cannot get my columns to show currencies, just plain numeric values.
I want my grid to show the "buyprice" and totalcost columns as "{0:C}" or "{0:$###.##}"
Here's my code:
.aspx
| <telerik:RadGrid |
| ID="RadGrid1" runat="server" |
| Width="95%" |
| OnNeedDataSource="RadGrid1_NeedDataSource" |
| > |
| <MasterTableView AutoGenerateColumns="false"> |
| <Columns> |
| <telerik:GridBoundColumn DataField="id" Visible="false" ReadOnly="true"></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="symbol" HeaderText="Symbol" ReadOnly="true" ></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="buyprice" HeaderText="Buy Price" DataType="System.Decimal" DataFormatString="{0:C}" ></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="totalcost" HeaderText="Total Cost" DataType="System.Decimal" DataFormatString="{0:C}" ></telerik:GridBoundColumn> |
| <telerik:GridButtonColumn ConfirmText="Are you sure?" ConfirmDialogType="Classic" ButtonType="ImageButton" ImageUrl="/images/delete.gif"CommandName="Delete"> |
| </telerik:GridButtonColumn> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
.aspx.cs
| protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e) |
| { |
| string XMLFilePath = getXMLPath(); |
| DataSet ds = new DataSet(); |
| ds.ReadXml(XMLFilePath); |
| DataView dv = new DataView(ds.Tables[0]); |
| dv.Sort = "datecalculated DESC"; |
| RadGrid1.DataSource = dv; |
| } |
.xml
| <?xml version="1.0" encoding="utf-8"?> |
| <calculations> |
| <calculation id="1" symbol="SYM1" buyprice="3.4" totalcost="831.483" datecalculated="06/30/2010" /> |
| <calculation id="2" symbol="SYM2" buyprice="10.74" totalcost="1088" datecalculated="06/17/2010" /> |
| </calculations> |
am I missing anything? Is my method of populating RadGrid1 causing this, can string formatting not be applied to boundcolumns? (I did try using GridNumericColumn, still without success).