vb.net - How to fill empty textboxes with some value while updating database? -


i have form containing 6 groupboxes , 120 textboxes. during data updation data base, empty textboxes return value "-na-". tried following codes keep getting errors:

     integer = 1 20         if groupbox1.controls("collartb" & i).text = string.empty             groupbox1.controls("collartb" & i).text = "-na-"         end if          if me.groupbox1.controls("collartb" & i).text = string.empty             me.controls("collartb" & i).text = "-na-"         end if          if form9.controls(i).text = string.empty             form9.controls(i).text = "-na-"         end if      next            if frnttb1.text = string.empty frnttb1.text = "-na-" 

how can done? solutions please?

also, have containing 180 textboxes in groupbox. want populate them single row of database @ once. possible? if so, how?

you can use linq filter groupboxes form , in groupboxes can filter out textboxes , set values textboxes per requirement. try code,

linq type i:

for each xgroupbox groupbox in me.controls.oftype(of groupbox)()      each xtextbox textbox in xgroupbox.controls.oftype(of textbox)()          if xtextbox.name.startswith("collartb") andalso xtextbox.text = string.empty             xtextbox.text = "-na-"         end if      next  next 

linq type ii:

 each xgroupbox groupbox in me.controls.oftype(of groupbox)()      each xtextbox textbox in xtxtbx in xgroupbox.controls.oftype(of textbox)() xtxtbx.text.startswith("collartb") , xtxtbx.text = string.empty          xtextbox.text = "-na-"      next  next 

non linq version:

for each xcontrols control in me.controls      if typeof xcontrols groupbox          each xcontrols1 control in xcontrols.controls              if typeof xcontrols1 textbox                  if xcontrols1.name.startswith("collartb") andalso xcontrols1.text = string.empty                       xcontrols1.text = "-na-"                  end if              end if          next      end if     next 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -