473,659 Members | 2,646 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validation for DataGrid

Hello NG

ASP:NET c# 1.1
I have to develop an existing c#, web application.
There is a datagrid.
With the Edit/Update function, where you could edit the value within the row.

I need a validation for numeric datatyp.
How could I insert a validation for this. It could be JavaScript, that onblur - event

With "normal" text boxes I do this
this.txtNumberR ooms.Attributes .Add("onblur", "javascript:Che ckNumber(this, 4);");

Thank You

But with the Datagrid i have now idea.

Regards

Matthias



Nov 18 '05 #1
2 4394
Matthias Marx wrote:
I need a validation for numeric datatyp.
How could I insert a validation for this. It could be JavaScript,
that onblur - event

With "normal" text boxes I do this
this.txtNumberR ooms.Attributes .Add("onblur",
"javascript:Che ckNumber(this, 4);");


woah there....there' s a much simpler way to do this, and not just within a
DataGrid.

Use a System.Web.UI.W ebControls.Comp areValidator; something like this :

<asp:TextBox id="IntegerValu e" runat="server"/>
<asp:CompareVal idator
ControlToValida te="IntegerValu e"
Operator="DataT ypeCheck"
Type="Integer"
ErrorMessage="- you must provide a valid Integer Value"
Display="Static "
runat="server"/>

The compare validator can check String, Integer, Double, Date or Currency
data types. It also gives you the advantage of performing both client side
*and* server side validation for you. By checking Page.IsValid on postback
you'll know whether or not the data entered is valid according to the rules
you've set up.

With ASP.NET there's really no reason to write your own client-side
validation routines for trivial data-types (and non-trivial ones can usually
be coped with by judicious use of the RegularExpressi onValidator).

HTH,
--
jo inferis
Nov 18 '05 #2
Hi,
One option is to use EditItemTemplat e for the grid. This lets you explicitly
specify the markup for the editable columns and hookup JS functions like
what you are looking for.

For a sample (at the bottom):
http://weblogs.asp.net/guys/articles/173646.aspx

"Matthias Marx" <ma***********@ nospam.gmx.net> wrote in message
news:uv******** ******@TK2MSFTN GP09.phx.gbl...
Hello NG

ASP:NET c# 1.1
I have to develop an existing c#, web application.
There is a datagrid.
With the Edit/Update function, where you could edit the value within the
row.

I need a validation for numeric datatyp.
How could I insert a validation for this. It could be JavaScript, that
onblur - event

With "normal" text boxes I do this
this.txtNumberR ooms.Attributes .Add("onblur", "javascript:Che ckNumber(this,
4);");

Thank You

But with the Datagrid i have now idea.

Regards

Matthias




Nov 18 '05 #3

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

Similar topics

1
1364
by: Hi | last post by:
I have a ASP.Net page that has a few fields to submit to a database and a datagrid to edit the entries. I have validation controls to make sure the user enters the right info on the first few fields. In the datagrid, I have it set up dynamic so they can edit the dtabase records from the database. They click edit and they can edit a few fields and then press either update or cancel. The problem I have now is that when the user presses...
3
1277
by: Stephen | last post by:
I have two datagrids on a page and each of them allow the user to add rows. On each datagrid I have validation (required field, reg expressions etc) and my problem is that I only want the validation to work on the datagrid which I click add in. At the moment if I click add in one datagrid and haven;t filled out anything on the other datagrid then the validation comes up. Does any one know what I can do to combat this?
1
1356
by: claire | last post by:
Hi, I have a windows form with a datagrid. The datagrid is bound to a typed dataset. Is there a built in validation function for windows forms? To validate the text boxes i have extended the textbox. However i am not sure how to perform validation on a datagrid. should i just catch the sql exceptions? Thank you in advance for any help you can give me, as i havent been able to
1
1179
by: Stephen | last post by:
I have two datagrids on a page and each of them allow the user to add rows. On each datagrid I have validation (required field, reg expressions etc) and my problem is that I only want the validation to work on the datagrid which I click add in. At the moment if I click add in one datagrid and haven;t filled out anything on the other datagrid then the validation comes up. Does any one know what I can do to combat this?
3
2996
by: Ben | last post by:
Hi, I have a page with a datagrid that you have to scroll to see. I'm using the StrengthControls SmartScroller as recommended to maintain my scroll position. Anyway, inside the datagrid I have fields that require validation. No problem, I put the validators on them and they work just fine... Except for the fact that when a user has an invalid entry and fires a validation event client side the scroll position is reset to the top of the...
2
1505
by: rodchar | last post by:
Hey all, I've got an asp.net page that has a textbox on it. The textbox has a requiredfieldvalidation associated with it. I've also got a datagrid with the edit,update,cancel links on it. When I run my app, and select the update link on the datagrid my textbox validation fires. Not sure why? Note: if i close the application and restart it it works fine. no error.
5
3239
by: Chris | last post by:
Based upon some prevoius postings on what to do for adding a 'add' row to a datagrid I utilize the footer to create the 'add' row. The only issue is that I have it sharing the 'UpDate_Command' and I use an argument to difference between an 'edit' vs. and 'add. But since I have field validation on both 'footer' and 'edit' columns I can't submit my edits since the footer validation kicks in.If I take the validation off then the both work fine...
4
2968
by: David Colliver | last post by:
Hi all, I am having a slight problem that hopefully, someone can help me fix. I have a form on a page. Many items on the form have validation controls attached. Also on this form are linkbuttons which must not cause validation. I have found a setting "causeValidation" to disable the validation. Also on the page, I have a datagrid that I will edit lines on. I can click
1
2376
by: Kris | last post by:
Hi, I have a DataGrid where in each row has couple of text boxes and an update button. Each row is dynamically generated as the number of rows are not known ahead of time. When the user clicks the update button, I do a postback to capture the data entered. However I dont want to do a postback when the textboxes are empty. How do I prevent this using Clientside validation? This is a common problem and if it has been beaten to death, please...
5
2049
by: Tina | last post by:
the Edit, Update, Cancel, and Delete buttons in my datagrid are causing validation elsewhere on the page. I want to specify that these buttons should not cause validation but they have no design time property of causevalidation. How can I keep them from causing validation? Thanks, T
0
8428
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
8339
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
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
8751
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
8535
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
8629
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
6181
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
5650
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();...
2
1982
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.