【ASP.NET Step by Step】之七 Master/Detail Filtering With a DropDownList
2008-12-11 16:05
447 查看
这一节比较简单,需要注意的主要有
1. Dropdownlist 控件要 Enable AutoPostback, 否则更改了list选择,Products Gridview不会跟随刷新
2. 添加新的 --choose a Category-- 要设置AppendDataBoundItems为True,否则Databind会覆盖掉它
<asp:DropDownList ID="categories" runat="server" AutoPostBack="True" DataSourceID="categoriesDataSource"
DataTextField="CategoryName" DataValueField="CategoryID" AppendDataBoundItems="True" EnableViewState="False">
<asp:ListItem Value="-1">-- Choose a Category --</asp:ListItem>
</asp:DropDownList>
3. 如果想让初始时显示所有产品,需要更改在ProductsBLL类中的GetProductsByCategoryID(categoryID)方法
public Northwind.ProductsDataTable GetProductsByCategoryID(int categoryID)
{
if (categoryID < 0)
return GetProducts();
else
return Adapter.GetProductsByCategoryID(categoryID);
}
1. Dropdownlist 控件要 Enable AutoPostback, 否则更改了list选择,Products Gridview不会跟随刷新
2. 添加新的 --choose a Category-- 要设置AppendDataBoundItems为True,否则Databind会覆盖掉它
<asp:DropDownList ID="categories" runat="server" AutoPostBack="True" DataSourceID="categoriesDataSource"
DataTextField="CategoryName" DataValueField="CategoryID" AppendDataBoundItems="True" EnableViewState="False">
<asp:ListItem Value="-1">-- Choose a Category --</asp:ListItem>
</asp:DropDownList>
3. 如果想让初始时显示所有产品,需要更改在ProductsBLL类中的GetProductsByCategoryID(categoryID)方法
public Northwind.ProductsDataTable GetProductsByCategoryID(int categoryID)
{
if (categoryID < 0)
return GetProducts();
else
return Adapter.GetProductsByCategoryID(categoryID);
}
相关文章推荐
- 【ASP.NET Step by Step】之八 Master/Detail Filtering With Two DropDownLists
- 【ASP.NET Step by STep】之九 Master/Detail Filtering Across Two Pages 之十 Master/Detail Using a Selectable Master GridView with a Details DetailView
- 【ASP.NET Step by Step】之四 Displaying Data With the ObjectDataSource
- Master/Detail Filtering With a DropDownList(Data Access Tutorial 7)
- [转]Bootstrap 3.0.0 with ASP.NET Web Forms – Step by Step – Without NuGet Package
- 【ASP.NET Step by Step】之三 Master Pages and Site Navigation
- Login control in an ASP.NET AJAX toolkit PopupControlExtender with a close button--write by Laurent Kempé
- ASP.NET组件设计Step by Step(3)
- ASP.NET组件设计Step by Step(9)
- ASP.NET MVC Step by Step中文版
- ASP.NET组件编程step by step
- Sorting, Filtering, and Paging with the Entity Framework in an ASP.NET MVC Application
- Create Asp.net ActiverX Step by Step
- ASP.NET MVC- VIEW Creating Page Layouts with View Master Pages Part 4
- 【ASP.NET step by step】之二 Create a BLL
- 最好的ASP.NET MVC入门 step by step 来自微软
- ASP.NET MVC Preview 3 STEP BY STEP 文章管理实例(一)
- ASP.NET组件设计Step by Step(5)
- ASP.NET组件设计Step by Step(7)
- ASP.NET组件编程step by step