在datagridview vb.net中验证电子邮件地址和号码

问题描述:

如何验证vb.net中datagridview的电子邮件地址列和电话号码列

请帮忙.. !!!

提前致谢

how to validate the email address column and the telephone number column of a datagridview in vb.net

Please help..!!!

Thankss in advancee


protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{

//Checking EditIndex should be same as current Row Index, then bind the validation controls in that particular row.

if (GridView1.EditIndex == e.Row.RowIndex)
{
RegularExpressionValidator regexpvalidator = new RegularExpressionValidator();
regexpvalidator.ID = "RegularExpressionValidator1";
regexpvalidator.ValidationExpression = "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
regexpvalidator.ControlToValidate = "TextBox4";
regexpvalidator.ErrorMessage = "Invalid Email Id";
regexpvalidator.SetFocusOnError = true;
e.Row.Cells[3].Controls.Add(regexpvalidator);

}
}
}



从以下链接中获取最佳示例;
^ ]
http://csharpdotnetfreak.blogspot.com/2011/12/createuserwizard-email-verification.html [^ ]



Get the best examples from following links;
http://www.asp.net/web-forms/tutorials/data-access/editing,-inserting,-and-deleting-data/adding-validation-controls-to-the-editing-and-inserting-interfaces-vb[^]
http://csharpdotnetfreak.blogspot.com/2011/12/createuserwizard-email-verification.html[^]