c# - How to declare var as global which stores value of controls? -


i have 2 radio buttons in criminalityinformationformviewdisposal , i'm finding controls dynamically follows

var siahasconvictions =  ((radiobuttonlist)criminalityinformationformviewdisposal.findcontrol(contactentity.sia_hascovictions)); var siahasoffencesawatingtrial =  ((radiobuttonlist)criminalityinformationformviewtrial.findcontrol(contactentity.sia_hasoffenceawaitingtrial)); 

now on 1 page whenever need fetch value of radio buttons i.e. whether selected or not every time need define var find control first , check value...now increases code line ..is there way can make findcontrol part global 1 page , access value normal control ,please me out this,as tried declare before page load,,,but gives error gridcontrol

there no easy way in opinion, might not repeat code on , on again:

private radiobuttonlist siahasconvictions {         {         return (radiobuttonlist)criminalityinformationformviewdisposal.findcontrol(contactentity.sia_hascovictions);     } } 

with property, can use this.siahasconvictions in code. optimize saving reference once in variable:

private radiobuttonlist _siahasconvictions; private radiobuttonlist siahasconvictions {         {         if (this._siahasconvictions == null)         {             this._siahasconvictions = (radiobuttonlist)criminalityinformationformviewdisposal.findcontrol(contactentity.sia_hascovictions);         }          return this._siahasconvictions;     } } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -