Validating Data in a GridView

Discussion in 'ASP .Net' started by Wannabe, May 21, 2008.

  1. Wannabe

    Wannabe Guest

    I have a gridview that uses a sqldatasource. The rows of the gridview are
    editable. When the gridview is in edit mode, one of the columns is a
    dropdown. In testing the editing, I deleted the dropdown entry from one of
    the rows. So, when the gridview comes up, it shows nothing in the column
    where I deleted it. Then when I select to edit that same row, I get an error
    because I cannot select the value for the dropdown for a non-existing value.
    This is not something that we anticipate happening very often, but since our
    tester caused it, we need to find a way to fix it. Question is...how can I
    validate the selected item of a dropdown when a gridview loads a selected row
    in edit mode, when the dropdown item does not exist. Hope this all makes
    sense.
    Wannabe, May 21, 2008
    #1
    1. Advertising

  2. If the lack of showing it means the user cannot edit it, you have a couple
    of choices.

    1. Add a disabled dropdown, or textbox, with the value. This will show the
    value, but not update it
    2. Remove the column from the update statement, so it is not included in the
    edit (this does not solve new records, of course, but you can default for
    additions)

    I am sure there are other ways to skin this cat.

    --
    Gregory A. Beamer
    MVP, MCP: +I, SE, SD, DBA

    Subscribe to my blog
    http://gregorybeamer.spaces.live.com/lists/feed.rss

    or just read it:
    http://gregorybeamer.spaces.live.com/

    *************************************************
    | Think outside the box!
    |
    *************************************************
    "Wannabe" <> wrote in message
    news:D...
    >I have a gridview that uses a sqldatasource. The rows of the gridview are
    > editable. When the gridview is in edit mode, one of the columns is a
    > dropdown. In testing the editing, I deleted the dropdown entry from one of
    > the rows. So, when the gridview comes up, it shows nothing in the column
    > where I deleted it. Then when I select to edit that same row, I get an
    > error
    > because I cannot select the value for the dropdown for a non-existing
    > value.
    > This is not something that we anticipate happening very often, but since
    > our
    > tester caused it, we need to find a way to fix it. Question is...how can I
    > validate the selected item of a dropdown when a gridview loads a selected
    > row
    > in edit mode, when the dropdown item does not exist. Hope this all makes
    > sense.
    Cowboy \(Gregory A. Beamer\), May 21, 2008
    #2
    1. Advertising

  3. Wannabe

    Wannabe Guest

    Thanks for the reply, but I thought I may have missed something. In one case,
    our tester was testing changing from one value (which was a very old value)
    to a newer value that was replacing it. The older value was already removed
    from the database before she attempted to update the row in the gridview to
    the newer value, which caused the blank column, then the error. Does that
    help clear it up?

    "Cowboy (Gregory A. Beamer)" wrote:

    > If the lack of showing it means the user cannot edit it, you have a couple
    > of choices.
    >
    > 1. Add a disabled dropdown, or textbox, with the value. This will show the
    > value, but not update it
    > 2. Remove the column from the update statement, so it is not included in the
    > edit (this does not solve new records, of course, but you can default for
    > additions)
    >
    > I am sure there are other ways to skin this cat.
    >
    > --
    > Gregory A. Beamer
    > MVP, MCP: +I, SE, SD, DBA
    >
    > Subscribe to my blog
    > http://gregorybeamer.spaces.live.com/lists/feed.rss
    >
    > or just read it:
    > http://gregorybeamer.spaces.live.com/
    >
    > *************************************************
    > | Think outside the box!
    > |
    > *************************************************
    > "Wannabe" <> wrote in message
    > news:D...
    > >I have a gridview that uses a sqldatasource. The rows of the gridview are
    > > editable. When the gridview is in edit mode, one of the columns is a
    > > dropdown. In testing the editing, I deleted the dropdown entry from one of
    > > the rows. So, when the gridview comes up, it shows nothing in the column
    > > where I deleted it. Then when I select to edit that same row, I get an
    > > error
    > > because I cannot select the value for the dropdown for a non-existing
    > > value.
    > > This is not something that we anticipate happening very often, but since
    > > our
    > > tester caused it, we need to find a way to fix it. Question is...how can I
    > > validate the selected item of a dropdown when a gridview loads a selected
    > > row
    > > in edit mode, when the dropdown item does not exist. Hope this all makes
    > > sense.

    >
    Wannabe, May 21, 2008
    #3
  4. If the older value, meaning the entire row, was deleted, you will have to
    set a default for that column, if it is a required field (not null in the
    database). If it was deleted after she grabbed it, the only protection is to
    ignore updates, or set it as a new row.

    If this does not help, I would consider rebuilding the grid. You can do it
    in a different page until you have it set. This will set things up correctly
    for your edits.

    I may have something that might help. I will have to dink it a bit as it was
    from a book that was never completed and the publisher still has the rights.
    I will also have to find it.

    --
    Gregory A. Beamer
    MVP, MCP: +I, SE, SD, DBA

    Subscribe to my blog
    http://gregorybeamer.spaces.live.com/lists/feed.rss

    or just read it:
    http://gregorybeamer.spaces.live.com/

    *************************************************
    | Think outside the box!
    |
    *************************************************
    "Wannabe" <> wrote in message
    news:...
    > Thanks for the reply, but I thought I may have missed something. In one
    > case,
    > our tester was testing changing from one value (which was a very old
    > value)
    > to a newer value that was replacing it. The older value was already
    > removed
    > from the database before she attempted to update the row in the gridview
    > to
    > the newer value, which caused the blank column, then the error. Does that
    > help clear it up?
    >
    > "Cowboy (Gregory A. Beamer)" wrote:
    >
    >> If the lack of showing it means the user cannot edit it, you have a
    >> couple
    >> of choices.
    >>
    >> 1. Add a disabled dropdown, or textbox, with the value. This will show
    >> the
    >> value, but not update it
    >> 2. Remove the column from the update statement, so it is not included in
    >> the
    >> edit (this does not solve new records, of course, but you can default for
    >> additions)
    >>
    >> I am sure there are other ways to skin this cat.
    >>
    >> --
    >> Gregory A. Beamer
    >> MVP, MCP: +I, SE, SD, DBA
    >>
    >> Subscribe to my blog
    >> http://gregorybeamer.spaces.live.com/lists/feed.rss
    >>
    >> or just read it:
    >> http://gregorybeamer.spaces.live.com/
    >>
    >> *************************************************
    >> | Think outside the box!
    >> |
    >> *************************************************
    >> "Wannabe" <> wrote in message
    >> news:D...
    >> >I have a gridview that uses a sqldatasource. The rows of the gridview
    >> >are
    >> > editable. When the gridview is in edit mode, one of the columns is a
    >> > dropdown. In testing the editing, I deleted the dropdown entry from one
    >> > of
    >> > the rows. So, when the gridview comes up, it shows nothing in the
    >> > column
    >> > where I deleted it. Then when I select to edit that same row, I get an
    >> > error
    >> > because I cannot select the value for the dropdown for a non-existing
    >> > value.
    >> > This is not something that we anticipate happening very often, but
    >> > since
    >> > our
    >> > tester caused it, we need to find a way to fix it. Question is...how
    >> > can I
    >> > validate the selected item of a dropdown when a gridview loads a
    >> > selected
    >> > row
    >> > in edit mode, when the dropdown item does not exist. Hope this all
    >> > makes
    >> > sense.

    >>
    Cowboy \(Gregory A. Beamer\), May 21, 2008
    #4
    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. panche
    Replies:
    1
    Views:
    526
    Peter Blum
    Jul 21, 2005
  2. Kevin Partin

    Validating XML data

    Kevin Partin, Feb 11, 2004, in forum: XML
    Replies:
    1
    Views:
    439
    peterpeter
    Feb 12, 2004
  3. Group IIS

    Trouble validating data

    Group IIS, Nov 10, 2004, in forum: XML
    Replies:
    4
    Views:
    724
    Lady Chatterly
    Nov 18, 2004
  4. Mike P
    Replies:
    0
    Views:
    350
    Mike P
    Jun 4, 2006
  5. Just Me

    Validating Dates In GridView

    Just Me, Mar 21, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    350
Loading...

Share This Page