Calling date conversion function before binding the date to a daragrid

Discussion in 'ASP .Net Web Controls' started by Sanjeeb, Jan 24, 2004.

  1. Sanjeeb

    Sanjeeb Guest

    I want to bind the date fteched from database to a datadrid. Date stored in data base is in UTC Time Format and I want to convert it to Local Time Format before binding it to the data grid. Now the challenege is not converting it to Local Time Format but to bind it to a datagrid. I can always have a function which can convert the UTC Format to Local Format. But, is there any datagrid event or any way in which that function can be called just before the date is bound to datagrid? The same issue seems pretty simple if I want the format converson which will be bound to any srver control like a text box or label. But, I don't know the way in which it can work for a datagrid.

    Any idea

    Thanks in advance
    sanjeeb
    Sanjeeb, Jan 24, 2004
    #1
    1. Advertising

  2. Sanjeeb

    Alvin Bruney Guest

    Have a look at the itemdatabound event handler. This event fires when each
    row of data in the underlying source is being bound to the datagrid. So you
    would be able to do
    e.Item.Cells[3].Text = DateTime.Now.AddDays(-1).ToString("yyyyMM"));

    --
    Regards,
    Alvin Bruney
    Got tidbits? Get it here...
    http://tinyurl.com/3he3b
    "Sanjeeb" <> wrote in message
    news:...
    > I want to bind the date fteched from database to a datadrid. Date stored

    in data base is in UTC Time Format and I want to convert it to Local Time
    Format before binding it to the data grid. Now the challenege is not
    converting it to Local Time Format but to bind it to a datagrid. I can
    always have a function which can convert the UTC Format to Local Format.
    But, is there any datagrid event or any way in which that function can be
    called just before the date is bound to datagrid? The same issue seems
    pretty simple if I want the format converson which will be bound to any
    srver control like a text box or label. But, I don't know the way in which
    it can work for a datagrid.
    >
    > Any idea?
    >
    > Thanks in advance,
    > sanjeeb
    Alvin Bruney, Jan 24, 2004
    #2
    1. Advertising

  3. Sanjeeb

    CMA Guest

    or else you can format the date time just before take from the database like
    this...

    string lstrQueary = "SELECT Convert(varchar(10), SentDate,103)+' '+
    Convert(varchar(10),Comment.SentDate,108) as formated_date FROM
    UserReminder;

    this will return the date as
    from Convert(varchar(10), SentDate,103) >>> 18/01/2004
    and from Convert(varchar(10),Comment.SentDate,108) >>> 10:24:30

    so you'll get the output for formated_date is "18/01/2004 10:24:30"

    hope this helps,
    CMA

    "Sanjeeb" <> wrote in message
    news:...
    > I want to bind the date fteched from database to a datadrid. Date stored

    in data base is in UTC Time Format and I want to convert it to Local Time
    Format before binding it to the data grid. Now the challenege is not
    converting it to Local Time Format but to bind it to a datagrid. I can
    always have a function which can convert the UTC Format to Local Format.
    But, is there any datagrid event or any way in which that function can be
    called just before the date is bound to datagrid? The same issue seems
    pretty simple if I want the format converson which will be bound to any
    srver control like a text box or label. But, I don't know the way in which
    it can work for a datagrid.
    >
    > Any idea?
    >
    > Thanks in advance,
    > sanjeeb
    CMA, Jan 26, 2004
    #3
    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. Ryan Ternier
    Replies:
    4
    Views:
    3,951
    Cowboy \(Gregory A. Beamer\) [MVP]
    Jul 29, 2004
  2. Karl
    Replies:
    1
    Views:
    573
    Hermit Dave
    Sep 14, 2004
  3. Kivanç Karaca

    Best way of databinding to a daragrid

    Kivanç Karaca, Oct 11, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    296
    Alex Homer
    Oct 11, 2004
  4. Andreas Lagemann
    Replies:
    8
    Views:
    456
    Mike Wahler
    Jan 10, 2005
  5. tiwy
    Replies:
    0
    Views:
    425
Loading...

Share This Page