vb.net - How to compare row values of two gridviews with dropdownlist column in asp.net? -


i have 2 gridviews. first 1 has dropdownlist. when user clicks button named 'show' data displayed on both gridviews data comes database. row data on column dropdownlist must compared rows on first column of second gridview. if equal messagebox prompt saying there's no changes , data not saved, else if not equal modal pop-up displayed asking if data correct.

below code comparing reads value of 1st row in gridview1.

 = 0 gridview1.rows.count - 1              dim ddl dropdownlist = directcast(gridview1.rows(i).cells(6).findcontrol("dropdowncriteria"), dropdownlist)             dim txt textbox = directcast(gridview1.rows(i).cells(7).findcontrol("txtreason"), textbox)               if ddl.selectedvalue = gridview2.rows(i).cells(0).text , txt.text = gridview2.rows(i).cells(1).text                  messagebox("no changes made! nothing saved.")                 return              else                  lblmsg.text = "are sure data you've selected/entered correct?"                 mdlpopupmsg.show()                 return              end if    next 

what must problem on this?

thanks in advance.

it reads first value (i=0) because return statements cause loop exit after first comparison. if want compare rows need variable keep track of result of if test each row. this:

    dim haschanges boolean = false     = 0 gridview1.rows.count - 1         ...         if ddl.selectedvalue = gridview2.rows(i).cells(0).text , txt.text = gridview2.rows(i).cells(1).text             'do nothing         else             haschanges = true         end if     next     if haschanges         messagebox("has changes.")     else         messagebox("no changes.")     end if 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -