Hojoformo
asked on
Dynamic DataGrid - DataFormatString?
How can I define a dataformat string for a datagrid created dynamically? Some of the columns of my datagrid need to be formated. For static datagrids I was using a command like "DataFormatString="{0:c})" but I do not know how to apply this for a dynamic datagrid.
e.Item.Cells[1].Wdith = Unit.Pixel(200);
e.Item.Cells[1].Style = "{0:c})" ??????? how do I format numeric and decimal fields???
e.Item.Cells[1].Wdith = Unit.Pixel(200);
e.Item.Cells[1].Style = "{0:c})" ??????? how do I format numeric and decimal fields???
ASKER
Thank you for your suggestion but I am having a little problem getting it to work. Can you help?
dgrdProducts.ItemDataBound += new DataGridItemEventHandler(D Grid_ItemD ataBound);
dgrdProducts.DataBind();
DataGrid parentDataGrid = ((DataGrid)sender); ???? Error - Specified cast is not valid????
((BoundColumn)parentDataGr id.Columns [1]).DataF ormatStrin g = "{0:c})";
Using the code you suggested I get an error "Specified Cast is Not Valid" . Any suggestions?
dgrdProducts.ItemDataBound
dgrdProducts.DataBind();
DataGrid parentDataGrid = ((DataGrid)sender); ???? Error - Specified cast is not valid????
((BoundColumn)parentDataGr
Using the code you suggested I get an error "Specified Cast is Not Valid" . Any suggestions?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try using:
DataGrid parentDataGrid = ((DataGrid)sender);
((BoundColumn)parentDataGr
I havent tested this but it should work;