网格视图的edititemtemplate文本框中的验证 [英] validation in textbox of edititemtemplate of a gridview

查看:163
本文介绍了网格视图的edititemtemplate文本框中的验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在该网格视图中,我有一个不为空的名称字段,一个phn no字段和一个电子邮件字段..所以我想借助asp控件的javascript no在每个目的上进行验证

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

推荐答案

http://www.aspdotnetcodes.com/GridView_Dynamic_Validation.aspx [< ^ ]

http://msdn.microsoft.com/en-us/library/ms972948.aspx [ ^ ]
http://www.dotnetspark.com/Forum/123-how-to-validate- gridview.aspx [ ^ ]
http://www.aspdotnetcodes.com/GridView_Dynamic_Validation.aspx[^]

http://msdn.microsoft.com/en-us/library/ms972948.aspx[^]
http://www.dotnetspark.com/Forum/123-how-to-validate-gridview.aspx[^]


首先,您只需将所有字段转换为模板字段,然后将Edit,Update,Delete重命名UpdateCommant更改为btnUpdate之类的名称,即可在您的计算机中创建1个JavaScript文件或代码带有3个参数的页面将被验证,并将此属性添加到btnUpdate的DataRowBound中


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


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')");

}
 {



您的JavaScript应该像这样



And Your JavaScript Be Shoud Be Like This

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

}



如果是行不通的,只需向我提供您的代码



If is will Not Work Just Provide Me Your Code


这篇关于网格视图的edititemtemplate文本框中的验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆