473,325 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Preventing Duplicate field information on gridview update?

Hello,
I have the need to verifiy a field in a gridview for a duplicate value
against a database before the update takes place. I was thinking that the
gridview1.rowupdating would be a good place to put code that can check for
duplicate data before the update happens.

Below is a sample of the code i was trying but did not work.

Protected Sub gvAssignedZones_RowUpdating(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles
gvAssignedZones.RowUpdating

'add a dup check for zones name before updateing.

Dim db As New
HydroClass.SchedulesTableAdapters.SelectNamedZones TableAdapter
Dim result As Object =
db.SelectDupZone(CType(gvAssignedZones.FindControl ("TextBox3"), TextBox).Text)
Dim lb As New Label
lb.Text =
db.SelectDupZone(CType(gvAssignedZones.FindControl ("TextBox3"),
TextBox).Text).ToString
If Not lb.Text =
db.SelectDupZone(CType(gvAssignedZones.FindControl ("TextBox3"),
TextBox).Text).ToString Then
If Not IsNothing(result) Then
gvAssignedZones.EditIndex = 0
Else
odsGVAssingedZones.Update()
End If
End If
End Sub
SO the idea here was to call an other tableadapter and add the value from
the correct field in the gridview and if the result was true or not nothing
then the gridview would stay in edit mode and if not the update from the
objectdatasource would kick in.

Yes I would also add an error message later this is just to test it first.

The idea of the Label was to see if the text was the same before updating
that way the duplicate check would be skipped in order to prevent errors.

Thank you,
Hawk
Feb 21 '07 #1
0 1572

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

Similar topics

5
by: Fred | last post by:
Hi out there, I have problems finding a way to warn a user that another user intends soon to update the same specific row. Let me explain. User 1 get to a JSP "update customer record" page....
1
by: JStrummer | last post by:
I just put together a PHP mailing list sign-up page that posts to a mySQL DB. The PHP script prevents INSERTs when the email address is already located in the database. Problem: I need to import...
1
by: Robert | last post by:
How can I query an existing table and update a field in each record in the table with the occurrence count of each record e.g. update field to 1 (= first record occurrence), update field to 2 for...
2
by: Emmett Power | last post by:
Hi, I have an Access table with a number of records which refer to the same person but with data in different fields. So for example the table would look like this: Name..............Field...
6
by: Oleg Konovalov | last post by:
Hi, I have a Java/JavaScript GUI application where I perform a lot of long DB operations , which takes 5-60 secs to perform. Sometimes user double-clicks the button or just gets impatient and...
4
by: afr0ninja | last post by:
Hello! I'm still rather new to using code in access. I've come across a problem that I'm having difficulty troubleshooting. Any assistance would be greatly appreciated! I've set up a form...
2
by: Ismail | last post by:
Hello, I have grid view which can go into edit mode. I have fields one of which is primary key I dont want to display this field but will use this field in my update method. If I make the...
1
BeemerBiker
by: BeemerBiker | last post by:
Using GridView and SqlDataSource I found that an index field defaults to "ReadOnly=True" and I have to change it to False and then hide it before my sql UPDATE command works. This seems awkward and...
4
by: justice750 | last post by:
Hi All, I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.