In the old UltraWebGrid you made a column format to currency by doing something like this.
grdResults.Columns[0].Format = "$###,###,##0.00";
How do you achieve this same effect with the new WebDataGrid?
Thanks!
Thanks its working as expected
Hi whanes,
Please feel free to contact us if you have any further questions regarding this matter.
Well, if you have not created any columns in your code behind or defined them in the aspx, the Columns collection will be empty. You'll need to define columns to access them in this way. Another option would be to access the column (our internally stored one) off a cell of that column. For example. grid.Rows[0].Items[0].Column.
-Dave
Ok I am still having some issues here. Ill admit i am not the most experinced Web Dev and I am probably missing something simple but here is what is going on.
I do
grdResults.DataSource = GetData();
grdResults.DataBind();
Then to format the column.
((Infragistics.Web.UI.GridControls.BoundDataField)grdResults.Columns[grdResults.Columns.Count - 1]).DataFormatString = "{0: $###,###,##0.00}";
I think get a object not set to a instance error, which appears to be because the columns in the grid do not exist yet. Which is rather confusing.
What exactly do i need to do to correct this? Thanks so much!
HI,
If you were only autogenerating columns, you would have gotten a null ref exception or index out of bounds. The problem is you did not type cast. The indexer for Columns returns a GridField. DataFormatString does not exist on this class. You need to typecast to BoundDataField, UnboundField (if it actually is one) or the super class of both, FormattedGridField.
regards,
David Young