473,654 Members | 3,253 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to validate input with datagrid control?

How to validate input with datagrid control? i tried
the following code from msdn...i have problem in adding
handler to the columnchanging event..its not working for
me? any bug in this code? is there any other way to
validate input with datagrid control? waiting for good
solution.thanks in advance.

-suresh

-----------------------------------------------------
Private Sub Customers_Colum nChanging(ByVal sender As
Object, _
ByVal e As System.Data.Dat aColumnChangeEv entArgs)
' Only check for errors in the Product column
If (e.Column.Colum nName.Equals("P roduct")) Then
' Do not allow "Automobile " as a product.
If CType(e.Propose dValue, String) = "Automobile "
Then
Dim badValue As Object = e.ProposedValue
e.ProposedValue = "Bad Data"
e.Row.RowError = "The Product column contians an
error"
e.Row.SetColumn Error(e.Column, "Product cannot
be " & _
CType(badValue, String))
End If
End If
End Sub
---------------------------------------------
Connect the event handler to the event.
Place the following code within either the form's Load
event or its constructor.

' Visual Basic
' Assumes the grid is bound to a dataset called
customersDataSe t1
' with a table called Customers.
' Put this code in the form's Load event or its
constructor.
AddHandler customersDataSe t1.Tables
("Customers").C olumnChanging, AddressOf
Customers_Colum nChanging

-----------------------------------------------------
Nov 20 '05 #1
0 2079

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

Similar topics

0
1337
by: MG | last post by:
The following below is Microsoft sample to validate a XML document. My question is how can I put the validate errors in DataGrid? Using the ValidationEventHandle subroutine and adding ListBox control in that event works find but i can't firgure out to use a DataGrid instead. Can someone help, Please.? Dim m_success As Boolean Public Sub ValidationEventHandle(ByVal sender As Object, ByVal args As ValidationEventArgs)
1
1512
by: mats | last post by:
Hell My problem is that I do not know how to validate input that I let the user type into my datagrid In one grid I let the user to type in a value into a template column - how do I make sure that this input is an integer on the client sid In a diffrent grid I have an edit command column and the same problem - how do I make sure that this is an integer on the client sid Any suggestion
11
2115
by: wolf | last post by:
There are three webcontrol on my asp.net form: a TextBox, a submit button and a RegularExpressionValidator. And I had set ControlToValidate property of the RegularExpressionValidator to the TextBox. But now, when I input a string in the textbox and press Enter key, the form was submit without client javascript validate. Why? And what should I do to enable client validate before submit the form whethe press Enter key or click Submit...
4
4278
by: Wysiwyg | last post by:
I need to validate a form to ensure that all of the fields add up correctly. I can't do this while the user is entering data since validation needs to be done after the entry is completed. What's the "best" way to validate prior to submitting? I could add an onsubmit attribute to the form which executes the validation in Javascript. That way the response doesn't need to be sent before validation takes place. Is this pretty much the way...
5
3268
by: sjl | last post by:
I've got an .aspx webform for searching my database. It basically takes user input and passes it as a parm into a stored proc to search a table. The results are returned in a SQLDataReader and bound to a datagrid on the same page. It works 90% of the time as expected. However, for some unknown reason, I randomly get the error below. The HttpException says there is an 'Invalid_Viewstate'. Ok, but why? I'm posting back to the same page. If...
0
978
by: Marina | last post by:
Let's say a user control has a bunch of textboxes. At some point the user control calls Validate to make sure all input is processed. The Validating event is fired, and if the input was invalid, e.Cancel is set to True. In this case Validate returns True or False correctly, based on whether the input was acceptable. But, if Validate is called from the parent form (or a user control that contains this user control), then the result is...
1
1870
by: satees | last post by:
Hi, I have a textbox control in Footer Template within datagrid. I need to validate the textbox using client side javascript. When trying it, i got an error that the control not exist. I think the datagrid sets some unique id to the textbox at runtime. Please help me how to do this ? Thanks in advance. Satees
3
4297
by: Max2006 | last post by:
Hi, I have a user control that has a property named "Text" Is there any way that I use a RequiredFieldValidator or CompareValidator to validate my user control's value? I tried it and I received this error: Control 'cboCountry' referenced by the ControlToValidate property of
1
3988
by: SkipNRun | last post by:
I am a novice when comes to JavaScript, AJAX. I am working on a form, which will allow users to update their contact information. In order to make the form flexible, I need to use pull down list. Depends on the pull down list selection, I use script.aculo.us to validate the user input before submit and pass the necessary data, such as contact type, contact information and ranking to a php program for updating. This form should allow multiple...
0
8379
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
8816
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8709
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...
1
8494
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8596
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
6162
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
5627
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2719
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
1
1924
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.