473,854 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validating Data in a GridView

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.
Jun 27 '08 #1
3 2190
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" <Wa*****@discus sions.microsoft .comwrote in message
news:D5******** *************** ***********@mic rosoft.com...
>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.
Jun 27 '08 #2
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" <Wa*****@discus sions.microsoft .comwrote in message
news:D5******** *************** ***********@mic rosoft.com...
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.
Jun 27 '08 #3
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" <Wa*****@discus sions.microsoft .comwrote in message
news:AC******** *************** ***********@mic rosoft.com...
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" <Wa*****@discus sions.microsoft .comwrote in message
news:D5******* *************** ************@mi crosoft.com...
>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.
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5680
by: theKirk | last post by:
using Visual Studio 2005 C# ASP.NET I know there has to be a simple way to do this....I want to use C# in a code behind for aspx. Populate a GridView from an xml file Add Fields to the GridView to allow entry of quantity and Y/N switch for
0
2441
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852 (http://support.microsoft.com/kb/810852), but then I realized that the hotfix mentioned was in .Net v1.1, which I am using. I took the sample from that article and recreated the situation I see in my application. (Code included below.) If you run the...
4
2623
by: Nalaka | last post by:
Hi, I have two questions about gridViews. 1. How can I intercept the row/column values at loading to change values? 2. After I update a row (using default update functionality), how can I re-format the updated row fields. I have looked at gridView.rowUpdated method, but cannot figure out how....
7
14826
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I want to look at that data and filter it based on what is in it. I know that this could have been done with data sets and data views in asp.net 1.1 but how is this done now in asp.net 2.0?
1
2317
by: Siva | last post by:
Hi, I have a 3 tier ASP.Net app for a handheld which needs to fetch orders from database via a DAL and populate it in a gridview using objectdatasource. In the search page I have a few parameters and when the search button is clicked I am sending those parameters via query string ( I need to do this since my app will run in a handheld which has certain restrictions). In the order list page, I am passing those parameters to the DAL as...
0
1018
by: Mike P | last post by:
How do you validate seperate controls in a gridview against each other? I have several controls that I need to compare the values of against each other in my gridview on editing. Any assistance would be really appreciated. *** Sent via Developersdex http://www.developersdex.com ***
5
6462
by: sutphinwb | last post by:
Hi - This could be a simple question. When I relate two tables in a datasetet, how do I get that relation to show up in a GridView? The only way I've done it, is to create a separate table in the dataset with a join query for the GetData() select method. I use ObjectDataStore to couple the GridView with the table adapter on the dataset. If I point the ODS at the child table, the GridView will bind to the "normal" select and I end up...
6
3715
by: rcoco | last post by:
Hi, I have a datagrid that is ment to insert data. But when I run the form only the header appears. I would like some advise from you all and solve this problem I'm using visual studio 2003. My code looks like this: private void Fill() { DataTable table = new DataTable(); SqlDataAdapter adapter = new SqlDataAdapter("SELECT * from
0
1303
by: jaz215 | last post by:
Hi i have an update page where i update data when a user select a row in the gridview, i also have a search function that displays the data in the gridview all those data that matched the search. my problem is that when i select the data after i search it the selected input would be coming from the previous gridiview look of the data example: standard gridview look Gridview 1strow 2ndrow 3rdrow
0
9899
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9750
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10672
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10362
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7909
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5738
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5937
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4149
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.