资源描述:
《外文翻译---数据捆绑技术》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、附录1英文原文TheDataBindingTechnologyInmyproject,IneedtoshowthedatafromtheDataBase,soIneedtousethedatabindingtechnologywhichMicrosoftcompanysupport.Inthefollowing,let'sdiscussittogether.IfyouarefamiliarwithclassicASP,thedeclarativedatabindingsyntaxintroducedinASP.NETwillbefamiliartoyoueventhoughthefunc
2、tionalityisvastlydifferent.Databindingexpressionsarethecodeyouseebetween<%#and%>charactersinanASPXfile.Theexpressionsallowyoutoeasilybindcontrolstodatasources,aswellasproperties,expressions,andresultsfrommethodcallsexposedbythepage.Whilethisfeatureiseasytouse,itoftencausessomeconfusionaboutwhatis
3、allowedandwhetheritshouldbeemployed.DatabindingbasicsDatabindingexpressionslinkASP.NETpageproperties,servercontrolproperties,anddatasourceswhenthepage'sDataBindmethodiscalled.Youcanplacedatabindingexpressionsonthevaluesideofanattribute/valuepairintheopeningtagofaservercontroloranywhereinthepage.A
4、lldatabindingexpressions,regardlessofwhereyouplacethem,mustbecontainedbetween<%#and%>characters.Whenusedwithdatacontrols(likeRepeater,DataGrid,andsoforth),theexpressionparameterisusuallyacolumnnamefromthedatasource.However,aslongasitreturnsavalue,anyvalidexpressionmaybeused.Likewise,thesamesyntax
5、maybeusedoutsidelistcontrols.Thisincludesdisplayingvaluesonthepageorpopulatingcontrolattributes.Container.DataItemisaruntimealiasfortheDataItemboundtoaspecificitem.Itmapstoanindividualitemfromthedatasourcelikeonerowfromadatabasequeryoranindividualelementfromanarray.TheactualdatatypefortheDataItem
6、isdeterminedbythedatasource.So,ifyou'redealingwithanarrayofintegers,theDataItemwillbeaninteger.ThefollowinglistprovidesaquickreviewoftheVB.NETsyntaxforvariousscenarios:<%#Container.DataItem%>--Anarrayofstringvaluesisreturned.<%#Container.DataItem("expression")%>--ThespecificfieldfromaDataViewcont
7、ainerisreturned.<%#Container.DataItem.PropertyName%>--Thespecificstringpropertyvalueofdatasourceisreturned.<%#CStr(Container.DataItem.PropertyName)%>--Returnsapropertyvalueconvertedtoitsstringrepresentation.Whenyou'reu