外文翻译 英文文献 使用两个DropDownList过滤的主从报表Word文件下载.docx
《外文翻译 英文文献 使用两个DropDownList过滤的主从报表Word文件下载.docx》由会员分享,可在线阅读,更多相关《外文翻译 英文文献 使用两个DropDownList过滤的主从报表Word文件下载.docx(25页珍藏版)》请在冰豆网上搜索。
scontentsbeingtheordersplacedbytheselectedcustomer.AGridViewwouldlistthelineitemsfromtheselectedorder.
WhiletheNorthwinddatabaseincludethecanonicalcustomer/order/orderdetailsinformationinitsCustomers,Orders,andOrderDetailstables,thesetablesaren'
tcapturedinourarchitecture.Nonetheless,wecanstillillustrateusingtwodependentDropDownLists.ThefirstDropDownListwilllistthecategoriesandthesecondtheproductsbelongingtotheselectedcategory.ADetailsViewwillthenlistthedetailsoftheselectedproduct.
Step1:
CreatingandPopulatingtheCategoriesDropDownList
OurfirstgoalistoaddtheDropDownListthatliststhecategories.Thesestepswereexaminedindetailintheprecedingtutorial,butaresummarizedhereforcompleteness.
OpentheMasterDetailsDetails.aspxpageintheFilteringfolder,addaDropDownListtothepage,setitsIDpropertytoCategories,andthenclicktheConfigureDataSourcelinkinitssmarttag.FromtheDataSourceConfigurationWizardchoosetoaddanewdatasource.
Figure1:
AddaNewDataSourcefortheDropDownList(Clicktoviewfull-sizeimage)
Thenewdatasourceshould,naturally,beanObjectDataSource.NamethisnewObjectDataSourceCategoriesDataSourceandhaveitinvoketheCategoriesBLLobject'
sGetCategories()method.
Figure2:
ChoosetoUsetheCategoriesBLLClass(Clicktoviewfull-sizeimage)
Figure3:
ConfiguretheObjectDataSourcetoUsetheGetCategories()Method(Clicktoviewfull-sizeimage)
AfterconfiguringtheObjectDataSourcewestillneedtospecifywhichdatasourcefieldshouldbedisplayedintheCategoriesDropDownListandwhichoneshouldbeconfiguredasthevalueforthelistitem.SettheCategoryNamefieldasthedisplayandCategoryIDasthevalueforeachlistitem.
Figure4:
HavetheDropDownListDisplaytheCategoryNameFieldandUseCategoryIDastheValue(Clicktoviewfull-sizeimage)
AtthispointwehaveaDropDownListcontrol(Categories)that'
spopulatedwiththerecordsfromtheCategoriestable.WhentheuserchoosesanewcategoryfromtheDropDownListwe'
llwantapostbacktooccurinordertorefreshtheproductDropDownListthatwe'
regoingtocreateinStep2.Therefore,checktheEnableAutoPostBackoptionfromthecategoriesDropDownList'
ssmarttag.
Figure5:
EnableAutoPostBackfortheCategoriesDropDownList(Clicktoviewfull-sizeimage)
Step2:
DisplayingtheSelectedCategory'
sProductsinaSecondDropDownList
WiththeCategoriesDropDownListcompleted,ournextstepistodisplayaDropDownListofproductsbelongingtotheselectedcategory.Toaccomplishthis,addanotherDropDownListtothepagenamedProductsByCategory.AswiththeCategoriesDropDownList,createanewObjectDataSourcefortheProductsByCategoryDropDownListnamedProductsByCategoryDataSource.
Figure6:
AddaNewDataSourcefortheProductsByCategoryDropDownList(Clicktoviewfull-sizeimage)
Figure7:
CreateaNewObjectDataSourceNamedProductsByCategoryDataSource(Clicktoviewfull-sizeimage)
SincetheProductsByCategoryDropDownListneedstodisplayjustthoseproductsbelongingtotheselectedcategory,havetheObjectDataSourceinvoketheGetProductsByCategoryID(categoryID)methodfromtheProductsBLLobject.
Figure8:
ChoosetoUsetheProductsBLLClass(Clicktoviewfull-sizeimage)
Figure9:
ConfiguretheObjectDataSourcetoUsetheGetProductsByCategoryID(categoryID)Method(Clicktoviewfull-sizeimage)
InthefinalstepofthewizardweneedtospecifythevalueofthecategoryIDparameter.AssignthisparametertotheselecteditemfromtheCategoriesDropDownList.
Figure10:
PullthecategoryIDParameterValuefromtheCategoriesDropDownList(Clicktoviewfull-sizeimage)
WiththeObjectDataSourceconfigured,allthatremainsistospecifywhatdatasourcefieldsareusedforthedisplayandvalueoftheDropDownList'
sitems.DisplaytheProductNamefieldandusetheProductIDfieldasthevalue.
Figure11:
SpecifytheDataSourceFieldsUsedforth