Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / May 2008

Tip: Looking for answers? Try searching our database.

Validating Data in a GridView

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wannabe - 21 May 2008 14:20 GMT
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) - 21 May 2008 14:32 GMT
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.

Signature

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!

*************************************************
>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
[quoted text clipped - 11 lines]
> in edit mode, when the dropdown item does not exist. Hope this all makes
> sense.
Wannabe - 21 May 2008 14:48 GMT
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 lack of showing it means the user cannot edit it, you have a couple
> of choices.
[quoted text clipped - 25 lines]
> > in edit mode, when the dropdown item does not exist. Hope this all makes
> > sense.
Cowboy (Gregory A. Beamer) - 21 May 2008 16:52 GMT
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.

Signature

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,
[quoted text clipped - 46 lines]
>> > makes
>> > sense.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.