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

Validation for a datagrid column

I have been trying to validate a textbox value, but unfortunately, the
test for its validity is a function that must look up a value in a SQL
database. The function returns true or false and that will determine
the validity of the entry which is itself in a datagrid. Can anyone
provide a sample of how this code would look? Sadly, I am terribly new
to ASP.NET, so if you could also elaborate on whether any specific code
must be in the ASP or the code-behind, I would appreciate it.

Nov 19 '05 #1
1 1255
I would suggest having a CustomValidator to do this. Add the custom validator
control to the .aspx page and in the .aspx.cs or .vb file, capture the
ServerValdiateEvent . In this event, write the code to connect to the
database and verify the value entered.
//Untested Pseudocode
public void ServerValidation(object sender, ServerValidateeventArgs args)
{
if(ValidateAgainstDB(txtVal.Text))
{
args.IsValid=false;
}

}
Here ValidateAgainstDB should verify the value against the database and
should return a true if the value is valid and false for Invalid
--
Aarthi R S

"st**********@gmail.com" wrote:
I have been trying to validate a textbox value, but unfortunately, the
test for its validity is a function that must look up a value in a SQL
database. The function returns true or false and that will determine
the validity of the entry which is itself in a datagrid. Can anyone
provide a sample of how this code would look? Sadly, I am terribly new
to ASP.NET, so if you could also elaborate on whether any specific code
must be in the ASP or the code-behind, I would appreciate it.

Nov 19 '05 #2

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

Similar topics

0
by: Mike | last post by:
I was wondering, can you use a validation control to valid user input from a DataGrid control? Example: let say you are editing one of row. before you update the data store, you valid the row and...
0
by: JR | last post by:
Hello, Does anyone know how you can prevent a row full of 'null' values from being added to the datagrid when a user hits the delete key, deleting the word (null) which represents the default...
4
by: RobS | last post by:
Can anyone answer this question: How can I disable validation when edit column update button is pressed. Can it be done for the whole grid? Regards, Robert
1
by: Jason | last post by:
I have created a datagrid with several template columns and included validation controls in the template columns. I also have a button column with edit-update-cancel. When the datagrid item is...
6
by: rodchar | last post by:
Hey all, I'm trying to implement validation in my asp.net datagrid. For example, if a user enters in a Customer ID I want it to check a different data table to see if the customer exists. I'm...
5
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...
4
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...
1
by: rmccinc | last post by:
OK, I am running into some issues that I cant figure out a work-around. I am not going to post code cause I figured out WHY my issue is happening: -I have a datagrid, and a button that fires a...
5
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...
1
by: Tom | last post by:
I have seen articles saying that validating the data a user enters into a datagrid is difficult, because it is not the datagrid itself that does the validation, but rather textboxes that are in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...

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.