Why can't I read a date out a cell in a gridview

Discussion in 'ASP .Net' started by COHENMARVIN@lycos.com, Jun 19, 2008.

  1. Guest

    I have code like this:
    FromRow = GridViewPlacementsForDups.SelectedRow
    strCellContents = FromRow.Cells(4).Text
    It works fine for most of the cells in the row. But cell #4 (above)
    has a date in it, and when I run the debugger, strCellContents is
    blank.
    Am I doing something wrong?
    Thanks,
    Marv
     
    , Jun 19, 2008
    #1
    1. Advertising

  2. Guest

    On Jun 19, 4:28 pm, "Mark Rae [MVP]" <> wrote:
    > <> wrote in message
    >
    > news:...
    >
    > >I have code like this:
    > > FromRow = GridViewPlacementsForDups.SelectedRow
    > > strCellContents = FromRow.Cells(4).Text
    > > It works fine for most of the cells in the row. But cell #4 (above)
    > > has a date in it, and when I run the debugger, strCellContents is
    > > blank.
    > > Am I doing something wrong?

    >
    > Is the date inside another control e.g. a label...?
    >
    > What is the value of FromRow.Cells(4).Controls.Count?
    >
    > --
    > Mark Rae
    > ASP.NET MVPhttp://www.markrae.net


    I found out the problem - which is that the date is in a template
    control, while the other fields of the grid are not.
    (The reason I had put in a template control was to format it).
    However, I also find that MSDN.microsoft.com gives wrong advice on
    getting the value out of this template control. So I've given up on
    that approach, and I've made the sql query return a string form of a
    date that doesn't have to be put in a template control.
    Thanks,
    Marv
     
    , Jun 20, 2008
    #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. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,278
    Michael Borgwardt
    May 30, 2004
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    912
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,002
    Smokey Grindel
    Dec 2, 2006
  4. Empire City
    Replies:
    3
    Views:
    414
    Empire City
    Apr 30, 2004
  5. Making a GridView Cell read-only

    , Nov 27, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    1,070
    Michael Tkachev
    Dec 19, 2006
Loading...

Share This Page