How can I assign the Format="%" property of a UltraGridColumn in .cs file based on the value of ID.
I know that we can assign Format property in InitializeLayout layout event. But here we cannot access the data. So how can add a Format property based on the value of other column data.
This is basically assigning a format at cell level.
Any ideas on this?
Hi satishgondimalla,
Thank you for posting in the community.
The Format property of an UltraWebGrid column is applied to all items in that column. You could, however, style cells individually based on some condition using the InitializeRow handler. Here is a sample implementation which would set a currency format to cells in the third column where the cell values in the first column for that row are even:
protected void UltraWebGrid1_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e) { if ( Int32.Parse(e.Row.Cells[0].Value.ToString()) %2 == 0) { e.Row.Cells[2].Value = String.Format("{0:c}", e.Row.Cells[2].Value); } }
Please note that the UltraWebGrid control is now outdated and as of .NetAdvantage 2011 Volume 2 is no longer included in our product package. I would suggest that you consider switching to the WebDataGrid/WebHieararchicalDataGrid. More information regarding these controls is available at:
http://help.infragistics.com/NetAdvantage/ASPNET/2011.2/CLR4.0/?page=Web_WebDataGrid_WebDataGrid.html
Additional samples demonstrating the features of these grids can be found at:http://samples.infragistics.com/aspnet/
Hope this helps.
Thanks for the sample. I made a tweak to get but it is still not working sometimes. Anyhow this looks good.
Hi satishgonimalla,
Please feel free to contact me if you have any questions regarding this scenario.