473,398 Members | 2,212 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,398 software developers and data experts.

Gridview Row_updating

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.SelectNamedZonesTableAdapte r

'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
Mar 20 '07 #1
1 1673
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.

"Hawk" wrote:
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.SelectNamedZonesTableAdapte r

'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
Mar 20 '07 #2

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

Similar topics

3
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...
6
by: Nalaka | last post by:
Hi, I have a gridView (grid1), which as a templateColumn. In the template column, I have put in a gridView (grid2) and a ObjectDataSource (objectDataSource2). Question is... How to I pass the...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
0
by: JayD | last post by:
I am using Visual Web Developer (vb.net) and have a gridview in a form. I can update records using standard EDIT/UPDATE buttons. However, there are two fields in every record (called ModifiedBy and...
2
by: antonyliu2002 | last post by:
I've been googling for some time, and could not find the solution to this problem. I am testing the paging feature of gridview. I have a very simple web form on which the user can select a few...
1
by: New Bee | last post by:
I have some questions related to the new GridView control. I dont seem to be able to get any values fromt he gridvieweventargs in the row_updated or row_updating events. Both the new and old...
1
by: nomad | last post by:
Hi, I have an editable GridView. When I select Edit it jumps into the RowEditing event. Within this even I can get the row index of the row being edited, along with the value of the column to...
3
by: Cralis | last post by:
Hi guys, I am new to GridViews.. I have a gridview that displays 3 columns. Description, MahUsed and a calculated % Used field. When I click Edit on the row, the MahUsed goes into Edit mode,...
3
by: Peter | last post by:
I have a GridView which is populated by List<ofObjects> Does anyone have example of how to sort the columns of this GridView? I have found examples without DataSourceControl but these use...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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...

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.