简体   繁体   中英

How do I Compare values in column of a gridview

I am using asp.net 4 and c#.

I have a gridview with a textbox that needs a unique value for the database. This value is to sort the data by precendence with in the database. All my other validators work but they only check the value in the one box.

How do I validate that the integers are unique in that column.

The only thing I found to do this is "DataKeyNames" but that does not stop it from allowing repeating numbers.

Updating the order is done on button click.

Thanks for info.

我想您可以编写一个JavaScript方法,在提交之前先扫描onclientclick网格的内容。

You can use a customvalidator for validating this. In the CustomValidator's OnServerValidate function you can repeat through all the rows of the grid view, get the textbox and its value and perform the unique check. For the Integer validation you can add a CompareValidator with Operator="DataTypeCheck" Type="Integer"

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM