Validating Data in a GridView

  • Thread starter Thread starter Wannabe
  • Start date Start date
W

Wannabe

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.
 
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!
|
*************************************************
 
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?
 
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!
|
*************************************************
 
Back
Top