Gridview Row_updating

G

Guest

Hello,
I have posted a similar question before with no response so I will try again
with new code.

I have a gridview that has code in the row_updating handler that checks to
see if a field has duplicate data in a database. If so the e.cancel is
called if not the update takes place.

What is happening is the update never takes place even if the data is new
and not a duplicate. It's like the e.cancel takes priority over all other
code. Here is a clip of my code. Any input would be greatly appreciated.

Thank you,
Hawk


'this code checks to see if the new value of the name field has a value.
If e.NewValues("name") IsNot Nothing Then

'If a value is present then I assign the value to a string.
Dim name As String = e.NewValues("name").ToString

'Here I call my data adapter
Dim db As New SchedulesTableAdapters.SelectNamedZonesTableAdapter

'assign the result of the query to the object "result" using the
string created above "name".

Dim result As Object = db.SelectDupZone(name)

'If result has a value then then name is already used and
updating is canceled.

If Not IsNothing(result) Then
e.Cancel = True
Label9.Text = " this name is used please try again"
Label9.Visible = True

'If result has no value the update should take place.

Else
e.Cancel = False
ObjectDataSource1.Update()
Label9.Visible = False
End If
End If
 
G

Guest

I have solved this problem!

It turns out that my data component or query's execute mode was using reader
instead of scalar. the reader was bringing back a value even if the search
was null. The value would be the name of the query.
 

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,780
Messages
2,569,608
Members
45,241
Latest member
Lisa1997

Latest Threads

Top