可以验证已经绑定的网格视图吗?
A | B | C | D
2 | 3 | a | 5例如,我想检查列中的数据是否是非字母的。在本例中,我想突出显示或告诉您在第二列第二行中有一个字母。
发布于 2011-05-17 18:13:49
像这样的东西就可以做到这一点。
Regex numeric = new Regex(@"^\d+$");
void GridView_RowDataBound(Object sender, GridViewRowEventArgs e) {
// check out all cells in the current row
foreach(var cell in e.Row.Cells) {
// do some validation thingy
if(!numeric.Match(cell.Text).Success) {
cell.CssClass = "error"; // put error class on the cell
}
}
}https://stackoverflow.com/questions/6028619
复制相似问题