formatting numbers & columns in datagrid

Discussion in 'ASP .Net' started by John Wilson, Sep 2, 2003.

  1. John Wilson

    John Wilson Guest

    I am still working away to get to grips with .NET web forms. Can anyone help
    me with these conundrums?

    How do I programmatically control the with of a datagrid itself and the
    columns in it? At the moment my grid is wider than the columns, leaving a
    spare bit to the right, and yet some of my columns are too narrow. Can I
    even get them to adjust automatically, eg to the width of the widest cell
    value?

    Also, how do I get numeric data to display correctly? The data comes from a
    sql query. I want it to display to 2 decimal places even if ".00", but at
    the moment I can't get it to give me those extra zeros whatever I do.

    I also had a problem figuring out how to right align the columns of figures.
    I fiddled with the GUI and managed this, but more by accident than design
    and I still don't know how I did it. In any event for future reference I
    want to know how to do it programatically.

    Has anyone any tips?

    --
    John Wilson
     
    John Wilson, Sep 2, 2003
    #1
    1. Advertising

  2. John Wilson

    George Durzi Guest


    > How do I programmatically control the with of a datagrid itself and the
    > columns in it? At the moment my grid is wider than the columns, leaving a
    > spare bit to the right, and yet some of my columns are too narrow. Can I
    > even get them to adjust automatically, eg to the width of the widest cell
    > value?


    Set AutoGenerateColumns to False, and add columns in the html or using the
    designer

    > Also, how do I get numeric data to display correctly? The data comes from

    a
    > sql query. I want it to display to 2 decimal places even if ".00", but at
    > the moment I can't get it to give me those extra zeros whatever I do.


    You might be best off handling this in your SQL query

    > I also had a problem figuring out how to right align the columns of

    figures.
    > I fiddled with the GUI and managed this, but more by accident than design
    > and I still don't know how I did it. In any event for future reference I
    > want to know how to do it programatically.


    you might be better off doing this in the html. After you've set
    AutoGenerateColumns to False and added some columns, you can set many
    properties of every column. Play around with the intellisense to explore.

    > Has anyone any tips?
    >
    > --
    > John Wilson
    >
    >
    >
     
    George Durzi, Sep 2, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. coleenholley

    DataGrid Formatting Columns ISsues

    coleenholley, Jan 30, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    388
    =?Utf-8?B?RGF2aWQgQ29l?=
    Feb 1, 2004
  2. John Wilson

    formatting numbers & columns in datagrid

    John Wilson, Sep 2, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    126
    John Wilson
    Sep 2, 2003
  3. rob thomson
    Replies:
    0
    Views:
    273
    rob thomson
    Sep 4, 2003
  4. DaVBGuy

    formatting columns in datagrid using XSD file

    DaVBGuy, Apr 27, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    153
    DaVBGuy
    Apr 27, 2005
  5. ton
    Replies:
    2
    Views:
    211
    Alvin Bruney [MVP]
    Feb 11, 2004
Loading...

Share This Page