473,396 Members | 1,799 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,396 software developers and data experts.

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_ColumnChanging(ByVal sender As
Object, _
ByVal e As System.Data.DataColumnChangeEventArgs)
' Only check for errors in the Product column
If (e.Column.ColumnName.Equals("Product")) Then
' Do not allow "Automobile" as a product.
If CType(e.ProposedValue, String) = "Automobile"
Then
Dim badValue As Object = e.ProposedValue
e.ProposedValue = "Bad Data"
e.Row.RowError = "The Product column contians an
error"
e.Row.SetColumnError(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
customersDataSet1
' with a table called Customers.
' Put this code in the form's Load event or its
constructor.
AddHandler customersDataSet1.Tables
("Customers").ColumnChanging, AddressOf
Customers_ColumnChanging

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

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

Similar topics

0
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...
1
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...
11
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...
4
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...
5
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...
0
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,...
1
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...
3
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...
1
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. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.