Yep, good catch! :-)

On Oct 6, 9:27 pm, Andrew Badera <[email protected]> wrote:
> It's not that autogenerated columns aren't added to the Columns
> collection, I don't believe -- it's that in PreRender, the grid hasn't
> been bound yet. Try doing your work in OnRowDataBound instead.
>
> ∞ Andy Badera
> ∞ +1 518-641-1280
> ∞ This email is: [ ] bloggable [x] ask first [ ] private
> ∞ Google me:http://www.google.com/search?q=andrew%20badera
>
>
>
> On Mon, Oct 5, 2009 at 11:13 AM, Paul <[email protected]> wrote:
>
> > 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- Hide quoted text -
>
> - Show quoted text -

Reply via email to