Time Format in datagrid (Hours, Minutes, Seconds)

Discussion in 'ASP .Net Datagrid Control' started by Eric, Aug 12, 2004.

  1. Eric

    Eric Guest

    I have a column in my database that stores total seconds. I want to
    bind this colum to my datagrid. Is there a way to have the time show
    as hours, minutes, and seconds without me having to build a custom
    function to handle this.

    The database column value is: 120 seconds

    I want it to say "2 Minutes" or "0:02:00".

    Any ideas?

    Thanks!
     
    Eric, Aug 12, 2004
    #1
    1. Advertising

  2. you mean as in a setting? no. you have to handle the itemdatabound event and
    do something like
    DateTime time = DateTime.Parse(e.Item.Cells[index].text );
    e.Item.Cells[index].text = Datelabel.Text = time.ToString("hh:mm:ss");
    roughly


    --
    Regards,
    Alvin Bruney
    [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
    Got tidbits? Get it here... http://tinyurl.com/27cok
    "Eric" <> wrote in message
    news:...
    >I have a column in my database that stores total seconds. I want to
    > bind this colum to my datagrid. Is there a way to have the time show
    > as hours, minutes, and seconds without me having to build a custom
    > function to handle this.
    >
    > The database column value is: 120 seconds
    >
    > I want it to say "2 Minutes" or "0:02:00".
    >
    > Any ideas?
    >
    > Thanks!
     
    Alvin Bruney [MVP], Aug 12, 2004
    #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. tshad
    Replies:
    7
    Views:
    17,011
    tshad
    Mar 11, 2005
  2. 00_CP_D12
    Replies:
    3
    Views:
    8,936
    dilipv
    Feb 22, 2008
  3. Stu
    Replies:
    7
    Views:
    1,773
    Dave Thompson
    Mar 7, 2005
  4. `p
    Replies:
    7
    Views:
    381
    Steve Litt
    Dec 14, 2005
  5. lemonhead71
    Replies:
    0
    Views:
    1,448
    lemonhead71
    Oct 3, 2012
Loading...

Share This Page