Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Validating Data in a GridView

Reply
Thread Tools

Validating Data in a GridView

 
 
Wannabe
Guest
Posts: n/a
 
      05-21-2008
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.
 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      05-21-2008
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" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
>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.


 
Reply With Quote
 
 
 
 
Wannabe
Guest
Posts: n/a
 
      05-21-2008
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" <(E-Mail Removed)> wrote in message
> news(E-Mail Removed)...
> >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.

>

 
Reply With Quote
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      05-21-2008
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news(E-Mail Removed)...
>> >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.

>>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Validating Dates In GridView Just Me ASP .Net 2 03-21-2008 09:10 PM
validating controls in gridview against each other Mike P ASP .Net 0 06-04-2006 07:43 PM
GridView Hierarchical View - Gridview in Gridview =?Utf-8?B?bWdvbnphbGVzMw==?= ASP .Net 1 05-09-2006 06:48 PM
Validating Data on User Control and Passing Back to the Page panche ASP .Net 1 07-21-2005 04:58 PM
Validating XML data Kevin Partin XML 1 02-12-2004 09:42 AM



Advertisments