Datagrid column formatting

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Datagrid column formatting

    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


    Kelly Guest

  2. Similar Questions and Discussions

    1. Formatting Date in Column of DataGrid
      Hi guys, I have a WebServiceConnector component which is bound to a DataSet component, which is in turn bound to a DataGrid component. All is...
    2. Formatting the phone nos in the column in the datagrid
      I want to format the phone nos displayed in the column of the datagrid to ###-###-#### i tried the following in the ItemCreated event but is not...
    3. Formatting datagrid column to show boolean as Yes/no instead of truefalse
      Is there a way to change the formatting expression of a column in the property builder of the datagrid to make boolean values appear as yes/no...
    4. DataGrid formatting - only one column without borders
      Yes, it is possible do it on datagrid ItemCreate event: int i = getMyNonBorderColumnIndex(); e.Item.Cells.Style.Add("BORDER-TOP-STYLE",...
    5. How to use formatting expression on DataGrid bound column.
      Refer http://www.c-sharpcorner.com/Code/2003/June/FormatDataGridData.asp http://www.c-sharpcorner.com/Code/2003/June/DataFormatString.asp HTH...
  3. #2

    Default Datagrid column formatting

    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
    [email]elton_wang@hotmail.com[/email]


    >-----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
    >
    >
    >.
    >
    Elton W Guest

  4. #3

    Default Re: Datagrid column formatting

    Thank you! I'll fiddle with this a bit. :)

    -Kelly

    "Elton W" <anonymous@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
    > [email]elton_wang@hotmail.com[/email]
    >
    >
    >
    > >-----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
    > >
    > >
    > >.
    > >

    Kelly Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139