Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in that grid view i have a name field which is not be blank,a phn no field and an email field..so i want to put validation on each purpose with the help of javascript no by the asp controls
Posted
Updated 16-Oct-12 2:12am
v2
Comments
Bhushan Shah1988 16-Oct-12 7:02am    
what kind of validation you want in textbox of edititemtemplat of a gridview?
arnabdattachaudhuri 16-Oct-12 7:44am    
in that grid view i have a name field which is not be blank,a phn no field and an email field..so i want to put validation on each purpose with the help of javascript no by the asp controls

 
Share this answer
 
v2
Comments
arnabdattachaudhuri 16-Oct-12 7:21am    
dude i want t o do it by using javascript... not with the asp validator controls....
vivektiwari97701 16-Oct-12 7:31am    
just Update Your Qstn. what type of validation u want like for numerical or For Mobile No . etc if u have some other custom validation just let me know ok.if you are using AJAX then most of the validation u can cover using FilterTextBox and rest of Validation You Can use javaScript.
arnabdattachaudhuri 16-Oct-12 7:45am    
in that grid view i have a name field which is not be blank,a phn no field and an email field..so i want to put validation on each purpose with the help of javascript no by the asp controls
arnabdattachaudhuri 16-Oct-12 7:35am    
in that grid view i have a name field which is not be blank,a phn no field and an email field..so i want to put validation on each purpose with the help of javascript no by the asp controls
Bhushan Shah1988 16-Oct-12 8:11am    
provide your sample code..!!
First Of All U Just Convert Your All Fild Into Template Field Along With Edit,Update,Delete Rename UpdateCommant To some name Like btnUpdate Create 1 javaScript File Or Code In Your Page With 3 Arguments wich is to be Validate and add this Attribute In DataRowBound for btnUpdate


C#
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
 {
 if (e.Row.RowType == DataControlRowType.DataRow)
{
TextBox TextBox1 = ((TextBox)GridView1.Rows[e.RowIndex].Cells[0].FindControl("TextBox1"));
TextBox TextBox2 = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].FindControl("TextBox2"));
TextBox TextBox3 = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].FindControl("TextBox3"));


linkButton BtnUpdate= ((linkButton )GridView1.Rows[e.RowIndex].Cells[2].FindControl("tnUpdate"));
BtnUpdate.Attributes.Add("onclick", "return validate('TextBox3.ClientID','TextBox3.ClientID','TextBox3.ClientID')");

}
 {


And Your JavaScript Be Shoud Be Like This

JavaScript
function validate(name,Mobile,Email)
{
Validation For Name 
Validation For Mobile
Validation For Email

}


If is will Not Work Just Provide Me Your Code
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900