Validating Data in a GridView

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.
 
C

Cowboy \(Gregory A. Beamer\)

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.
 
W

Wannabe

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?
 
C

Cowboy \(Gregory A. Beamer\)

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top