资源描述:
《外文翻译---数据捆绑技术》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、附录1英文原文TheDataBindingTechnologyInmyproject,IneedtoshowthedatafromtheDataBase,soIneedtousethedatabindingtechnologywhichMicrosoftcompanysupport.Inthefollowing,let'sdiscussittogether.IfyouarefamiliarwithclassicASP,thedeclarativedatabindingsyntaxintroducedinA
2、SP.NETwillbefamiliartoyoueventhoughthefunctionalityisvastlydifferent.Databindingexpressionsarethecodeyouseebetween<%#and%>charactersinanASPXfile.Theexpressionsallowyoutoeasilybindcontrolstodatasources,aswellasproperties,expressions,andresultsfrommethodcal
3、lsexposedbythepage.Whilethisfeatureiseasytouse,itoftencausessomeconfusionaboutwhatisallowedandwhetheritshouldbeemployed.DatabindingbasicsDatabindingexpressionslinkASP.NETpageproperties,servercontrolproperties,anddatasourceswhenthepage'sDataBindmethodiscal
4、led.Youcanplacedatabindingexpressionsonthevaluesideofanattribute/valuepairintheopeningtagofaservercontroloranywhereinthepage.Alldatabindingexpressions,regardlessofwhereyouplacethem,mustbecontainedbetween<%#and%>characters.Whenusedwithdatacontrols(likeRepe
5、ater,DataGrid,andsoforth),theexpressionparameterisusuallyacolumnnamefromthedatasource.However,aslongasitreturnsavalue,anyvalidexpressionmaybeused.Likewise,thesamesyntaxmaybeusedoutsidelistcontrols.Thisincludesdisplayingvaluesonthepageorpopulatingcontrolat
6、tributes.Container.DataItemisaruntimealiasfortheDataItemboundtoaspecificitem.Itmapstoanindividualitemfromthedatasourcelikeonerowfromadatabasequeryoranindividualelementfromanarray.TheactualdatatypefortheDataItemisdeterminedbythedatasource.So,ifyou'redealin
7、gwithanarrayofintegers,theDataItemwillbeaninteger.ThefollowinglistprovidesaquickreviewoftheVB.NETsyntaxforvariousscenarios:<%#Container.DataItem%>--Anarrayofstringvaluesisreturned.<%#Container.DataItem("expression")%>--ThespecificfieldfromaDataViewcontain
8、erisreturned.<%#Container.DataItem.PropertyName%>--Thespecificstringpropertyvalueofdatasourceisreturned.<%#CStr(Container.DataItem.PropertyName)%>--Returnsapropertyvalueconvertedtoitsstringrepresentation.Whenyou'reu