Hello All,

I am trying to set the DataFormatString for a GridView
programmatically. I've been struggling with this all morning. I have
tried something like this line of code in the grids PreRender event,
and all the other grid events.

((BoundField)grdDrillDownData.Columns[0]).DataFormatString = "{0:d-MMM-
yyyy}";

I have figured out that there is at least one reason why my code is
not working and that is because columns that were auto generated are
not added to the columns collection. If that is the case then how can
I set the DataFormatString programmatically? Ultimately, I want to be
able to set the format string on a column based on the type of data
the column contains. It has to be done programmatically, because the
number of columns and the type of data in those columns is not known
until runtime.

Thanks in advance for any help,

Paul

Reply via email to