Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Datagrid column formatting

Reply
Thread Tools

Datagrid column formatting

 
 
Kelly
Guest
Posts: n/a
 
      04-22-2005
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


 
Reply With Quote
 
 
 
 
Elton W
Guest
Posts: n/a
 
      04-22-2005
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




>-----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
>
>
>.
>

 
Reply With Quote
 
 
 
 
Kelly
Guest
Posts: n/a
 
      04-22-2005
Thank you! I'll fiddle with this a bit.

-Kelly

"Elton W" <> wrote in message
news:12ae01c5477d$c8450de0$...
> 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
>
>
>
>
> >-----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
> >
> >
> >.
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How to use formatting expression on DataGrid bound column. Sonali.NET[MVP] ASP .Net 2 07-30-2006 03:18 PM
bind a dropdown in a column in a datagrid based on the dropdown value selected in another column of the datagrid. vishnu ASP .Net 1 03-25-2006 01:24 PM
how do i access a dropdownlists selected value in a datagrid edititemtemplate column from the selectedindexchanged event of another dropdownlist in a datagrid edititemtemplate column Dave M ASP .Net Datagrid Control 0 12-14-2004 11:53 AM
Data formatting expression wanted for dataset bound datagrid column for href Alex ASP .Net 0 04-14-2004 04:03 PM
Re: DataGrid formatting - only one column without borders Anatoly ASP .Net 1 07-15-2003 12:41 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57