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
Post a Comment