我的表单中有一个datagridview,如何在离开当前行时验证单元格。
在更改的每个选定索引上,保存当前索引,但是在保存之前,只需从上一个选定行中获取数据并进行验证即可。
Here's an answer for Windows Forms (the question is tagged ASP.NET but as far as I know there is no such thing as a DataGridView for the web):
Handle the RowValidating
event and validate the row there. If the row's values are invalid, set the error message in the ErrorText
property of the row, and set e.Cancel = True
.
Finally in the RowValidated
event, set the row's ErrorText
property to an empty string.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.