To Format the Hierarchical grid's column from integer to currency, below code can be used.
protected void UltraGrid1_InitializeLayout(object sender, LayoutEventArgs e)
{
UltraGrid1.DisplayLayout.Bands[0].Columns[10].Format = "$ #####0.00";
}
If we export the grid to Excel using UltraWebGridExcelExporter, that column will be integer only. To get in currency format use below code.
In Page_Load add CellExported event like below.
this.UltraWebGridExcelExporter1.CellExported += new Infragistics.WebUI.UltraWebGrid.ExcelExport.CellExportedEventHandler(UltraWebGridExcelExporter1_CellExported);
Code for CellExported event will be like below.
void UltraWebGridExcelExporter1_CellExported(object sender, Infragistics.WebUI.UltraWebGrid.ExcelExport.CellExportedEventArgs e)
{
if (e.GridColumn.Format == "$ #####0.00")
{ e.CurrentWorksheet.Rows[e.CurrentRowIndex].Cells[e.CurrentColumnIndex].CellFormat.FormatString = "$ #####0.00";
}
}
Subscribe to:
Post Comments (Atom)
awesome!!! solved my problem. thank you!!
ReplyDelete