Home All Groups Group Topic Archive Search About
Author
22 Apr 2005 4:30 PM
Kelly
Is it possible to set the column widths of a datagrid?

This is driving me crazy, and I haven't found a solution yet. I'm pretty new
to ASP.NET so there may be an easy way I'm just not aware of, however, I've
Googled this until my eyes hurt and still haven't found a solution.

Also, how would I set a few of my columns' format? (I have 3 date columns
within the datagrid and I'd like to set the format to dd/mm/yyyy or
something similar...)

Any and all help would be appreciated!

-Kelly

Author
22 Apr 2005 8:56 PM
Elton W
Hi

You can use HeaderStyle-Width and ItemStyle-Width of
column to set column width.

To format date in a BoundColumn:
DataFormatString="{0: MM/dd/yyyy}"

To format date in a TemplateColumn:
Text ='<%# DataBinder.Eval
(Container.DataItem, "DateField", "{0: dd/MM/yyyy}")'

HTH

Elton Wang
elton_w***@hotmail.com



>-----Original Message-----
>Is it possible to set the column widths of a datagrid?
>
>This is driving me crazy, and I haven't found a solution
yet. I'm pretty new
>to ASP.NET so there may be an easy way I'm just not aware
of, however, I've
>Googled this until my eyes hurt and still haven't found a
solution.
>
>Also, how would I set a few of my columns' format? (I
have 3 date columns
>within the datagrid and I'd like to set the format to
dd/mm/yyyy or
Show quoteHide quote
>something similar...)
>
>Any and all help would be appreciated!
>
>-Kelly
>
>
>.
>
Author
22 Apr 2005 9:53 PM
Kelly
Thank you! I'll fiddle with this a bit. :)

-Kelly

Show quoteHide quote
"Elton W" <anonym***@discussions.microsoft.com> wrote in message
news:12ae01c5477d$c8450de0$a401280a@phx.gbl...
> Hi
>
> You can use HeaderStyle-Width and ItemStyle-Width of
> column to set column width.
>
> To format date in a BoundColumn:
> DataFormatString="{0: MM/dd/yyyy}"
>
> To format date in a TemplateColumn:
> Text ='<%# DataBinder.Eval
> (Container.DataItem, "DateField", "{0: dd/MM/yyyy}")'
>
> HTH
>
> Elton Wang
> elton_w***@hotmail.com
>
>
>
> >-----Original Message-----
> >Is it possible to set the column widths of a datagrid?
> >
> >This is driving me crazy, and I haven't found a solution
> yet. I'm pretty new
> >to ASP.NET so there may be an easy way I'm just not aware
> of, however, I've
> >Googled this until my eyes hurt and still haven't found a
> solution.
> >
> >Also, how would I set a few of my columns' format? (I
> have 3 date columns
> >within the datagrid and I'd like to set the format to
> dd/mm/yyyy or
> >something similar...)
> >
> >Any and all help would be appreciated!
> >
> >-Kelly
> >
> >
> >.
> >