简体   繁体   中英

Gridview losing row index value

Iam having a gridview with textboxes in itemtemplate. If textbox validation fails whiling clicking the submit button gets into exception and loses its rowindex values. Based on the row index value iam setting theme for gridview rows. So when i click the row it throws null value exception. Help me to solve this. ( I dont wanna bind grid in catch block, since i have to maintain the values user entered in the textboxes)

you dont need to get to a point where your program is throwing an exception for something as trivial as mistakes in user input. have validators on your page do a client validation. and avcorse dont forget to check at the server side as well. i mean do not procced with your code unless validators are validated true like this:

if(Page.IsValid)

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