外文翻译 英文文献 使用两个dropdownlist过滤的主从报表大学毕设论文.docx

上传人:b****6 文档编号:4780653 上传时间:2022-12-08 格式:DOCX 页数:25 大小:963.72KB
下载 相关 举报
外文翻译 英文文献 使用两个dropdownlist过滤的主从报表大学毕设论文.docx_第1页
第1页 / 共25页
外文翻译 英文文献 使用两个dropdownlist过滤的主从报表大学毕设论文.docx_第2页
第2页 / 共25页
外文翻译 英文文献 使用两个dropdownlist过滤的主从报表大学毕设论文.docx_第3页
第3页 / 共25页
外文翻译 英文文献 使用两个dropdownlist过滤的主从报表大学毕设论文.docx_第4页
第4页 / 共25页
外文翻译 英文文献 使用两个dropdownlist过滤的主从报表大学毕设论文.docx_第5页
第5页 / 共25页
点击查看更多>>
下载资源
资源描述

外文翻译 英文文献 使用两个dropdownlist过滤的主从报表大学毕设论文.docx

《外文翻译 英文文献 使用两个dropdownlist过滤的主从报表大学毕设论文.docx》由会员分享,可在线阅读,更多相关《外文翻译 英文文献 使用两个dropdownlist过滤的主从报表大学毕设论文.docx(25页珍藏版)》请在冰豆网上搜索。

外文翻译 英文文献 使用两个dropdownlist过滤的主从报表大学毕设论文.docx

外文翻译英文文献使用两个dropdownlist过滤的主从报表大学毕设论文

Master/DetailFilteringWithTwoDropDownLists

Introduction

Intheprevioustutorialweexaminedhowtodisplayasimplemaster/detailsreportusingasingleDropDownListpopulatedwiththecategoriesandaGridViewshowingthoseproductsthatbelongtotheselectedcategory.Thisreportpatternworkswellwhendisplayingrecordsthathaveaone-to-manyrelationshipandcaneasilybeextendedtoworkforscenariosthatincludemultipleone-to-manyrelationships.Forexample,anorderentrysystemwouldhavetablesthatcorrespondtocustomers,orders,andorderlineitems.Agivencustomermayhavemultipleorderswitheachorderconsistingofmultipleitems.SuchdatacanbepresentedtotheuserwithtwoDropDownListsandaGridView.ThefirstDropDownListwouldhavealistitemforeachcustomerinthedatabasewiththesecondone'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:

SpecifytheDataSourceFieldsUsedfortheDropDownList'sListItems'TextandValueProperties(Clicktoviewfull-sizeimage)

WiththeObjectDataSourceandProductsByCategoryDropDownListconfiguredourpagewilldisplaytwoDropDownLists:

thefirstwilllistallofthecategorieswhilethesecondwilllistthoseproductsbelongingtotheselectedcategory.WhentheuserselectsanewcategoryfromthefirstDropDownList,apostbackwillensueandthesecondDropDownListwillberebound,showingthoseproductsthatbelongtothenewlyselectedcategory.Figures12and13showMasterDetailsDetails.aspxinactionwhenviewedthroughabrowser.

Figure12:

WhenFirstVisitingthePage,theBeveragesCategoryisSelected(Clicktoviewfull-sizeimage)

Figure13:

ChoosingaDifferentCategoryDisplaystheNewCategory'sProducts(Clicktoviewfull-sizeimage)

CurrentlytheproductsByCategoryDropDownList,whenchanged,doesnotcauseapostback.However,wewillwantapostbacktooccuronceweaddaDetailsViewtodisplaytheselectedproduct'sdetails(Step3).Therefore,checktheEnableAutoPostBackcheckboxfromtheproductsByCategoryDropDownList'ssmarttag.

Figure14:

EnabletheAutoPostBackFeaturefortheproductsByCategoryDropDownList(Clicktoviewfull-sizeimage)

Step3:

UsingaDetailsViewtoDisplayDetailsfortheSelectedProduct

ThefinalstepistodisplaythedetailsfortheselectedproductinaDetailsView.Toaccomplishthis,addaDetailsViewtothepage,setitsIDpropertytoProductDetails,andcreateanewObjectDataSourceforit.ConfigurethisObjectDataSourcetopullitsdatafromtheProductsBLLclass'sGetProductByProductID(productID)methodusingtheselectedvalueoftheProductsByCategoryDropDownListforthevalueoftheproductIDparameter.

Figure15:

ChoosetoUsetheProductsBLLClass(Clicktoviewfull-sizeimage)

Figure16:

ConfiguretheObjectDataSourcetoUsetheGetProductByProductID(productID)Method(Clicktoviewfull-sizeimage)

Figure17:

PulltheproductIDParameterValuefromtheProductsByCategoryDropDownList(Clicktoviewfull-sizeimage)

YoucanchoosetodisplayanyoftheavailablefieldsintheDetailsView.I'veoptedtoremovetheProductID,SupplierID,andCategoryIDfieldsandreorderedandformattedtheremainingfields.Inaddition,IclearedouttheDetailsView'sHeightandWidthproperties,allowingtheDetailsViewtoexpandtothewidthneededtobestdisplayitsdataratherthanhavingitconstrainedtoaspecifiedsize.Thefullmarkupappearsbelow:

DetailsViewID="ProductDetails"runat="server"AutoGenerateRows="False"DataKeyNames="ProductID"DataSourceID="ObjectDataSource1"EnableViewState="False">

BoundFieldDataField="ProductName"HeaderText="Product"SortExpression="ProductName"/>

BoundFieldDataField="CategoryName"HeaderText="Category"ReadOnly="True"SortExpression="CategoryName"/>

BoundFieldDataField="SupplierName"HeaderText="Supplier"ReadOnly="True"SortExpression="SupplierName"/>

BoundFieldDataField="QuantityPerUnit"HeaderText="Qty/Unit"SortExpression="QuantityPerUnit"/>

BoundFieldDataField="UnitPrice"DataFormatString="{0:

c}"HeaderText="Price"HtmlEncode="False"SortExpression="UnitPrice"/>

BoundFieldDataField="UnitsInStock"HeaderText="UnitsInStock"SortExpression="UnitsInStock"/>

BoundFieldDataField="UnitsOnOrder"HeaderText="UnitsOnOrder"SortExpression="UnitsOnOrder"/>

BoundFieldDataField="ReorderLevel"HeaderText="ReorderLevel"SortExpression="ReorderLevel"/>

CheckBoxFieldDataField="Discontinued"HeaderText="Discontinued"SortExpression="Discontinued"/>

DetailsView>

TakeamomenttotryouttheMasterDetailsDetails.aspxpageinabrowser.Atfirstglanceitmayappearthateverythingisworkingasdesired,butthere'sasubtleproblem.WhenyouchooseanewcategorytheProductsByCategoryDropDownListisupdatedtoincludethoseproductsfortheselectedcategory,buttheProductDetailsDetailsViewcontinuedtoshowthepreviousproductinformation.TheDetailsViewisupdatedwhenchoosingadifferentproductfortheselectedcategory.Furthermore,ifyoutestthoroughlyenough,you'llfindthatifyoucontinuallychoosenewcategories(suchaschoosingBeveragesfromtheCategoriesDropDownList,thenCondiments,thenConfections)everyothercategoryselectioncausestheProductDetailsDetailsViewtoberefreshed.

Tohelpconcretizethisproblem,let'slookataspecificexample.WhenyoufirstvisitthepagetheBeveragescategoryisselectedandtherelatedproductsareloadedintheProductsByCategoryDropDownList.ChaiistheselectedproductanditsdetailsaredisplayedintheProductDetailsDetailsView,asshowninFigure18.

Figure18:

TheSelectedProduct'sDetailsareDisplayedinaDetailsView(Clicktoviewfull-sizeimage)

IfyouchangethecategoryselectionfromBeveragestoCondiments,apostbackoccursand

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 高考

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1