Datagrid column formatting

K

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
 
E

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
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top