自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

ASP.NET DropDownList的創(chuàng)建與填充

開發(fā) 后端
本文概括介紹了如何創(chuàng)建asp.net DropDownList并使用類別數(shù)據(jù)對其進行填充。

我們的***個目標是添加一個能夠列出類別的DropDownList. 打開Filtering文件夾中的MasterDetailsDetails.aspx, 在頁面上添加一個DropDownList, 設置它的ID為Categories,然后單擊智能標記上的 Configure Data Source鏈接. 在數(shù)據(jù)源配置向導中選擇新增一個數(shù)據(jù)源.

為DropDownList增加一個新的數(shù)據(jù)源 

ASP.NET DropDownList: 為DropDownList增加一個新的數(shù)據(jù)源

當然, 新的數(shù)據(jù)源應該是ObjectDataSource. 把新的ObjectDataSource命名為CategoriesDataSource并且讓他調用CategoriesBLL對象的GetCategories()方法

選擇使用CategoriesBLL類 

ASP.NET DropDownList: 選擇使用CategoriesBLL類

配置ObjectDataSource使用GetCategories()方法 

ASP.NET DropDownList: 配置ObjectDataSource使用GetCategories()方法

配置完ObjectDataSource后還需要指定要在DropDownList中顯示的數(shù)據(jù)字段,以及作為數(shù)據(jù)項的值(value for the list item)的數(shù)據(jù)字段.我們指定CategoryName為要顯示的列,指定CategoryID為數(shù)據(jù)項的值字段

指定DropDownList 顯示CategoryName列并且使用CategoryID列作為數(shù)據(jù)項的值 

ASP.NET DropDownList: 指定DropDownList 顯示CategoryName列并且使用CategoryID列作為數(shù)據(jù)項的值

這時,我們就有了一個使用Categories表中的記錄來填充的DropDownList控件. 當用戶在DropDownList中選擇一個新的類別時, 我們需要一次回發(fā),這樣可以刷新在第二步中我們要創(chuàng)建的產品DropDownList控件. 所以, categoriesDropDownList的智能標記上選中AutoPostBack選項.

選中Categories DropDownList 的AutoPostBack  

ASP.NET DropDownList: 選中Categories DropDownList 的AutoPostBack

【編輯推薦】

  1. ASP.NET 2.0數(shù)據(jù)教程:給站點添加aspx頁面
  2. ASP.NET 2.0數(shù)據(jù)教程:創(chuàng)建母版頁
  3. ASP.NET跨頁面?zhèn)髦档募记?/A>
  4. ASP.NET 2.0數(shù)據(jù)教程:給DAL添加定制編碼
  5. ASP.NET 2.0數(shù)據(jù)教程:完成數(shù)據(jù)訪問層

 

責任編輯:book05 來源: 博客堂
相關推薦

2009-07-27 09:45:14

ASP.NET Dro

2009-10-29 09:15:32

ASP.NET MVCDropDownLis

2009-07-31 17:34:40

ASP.NET工作流

2009-07-23 14:21:55

ASP.NET頁面

2009-07-29 17:29:46

ASP與ASP.NET

2009-07-29 13:57:53

創(chuàng)建SlideShowASP.NET

2009-07-24 15:47:35

ASP.NET與ASP

2009-08-04 13:38:36

ASP.NET用戶控件

2009-07-23 15:18:30

創(chuàng)建XML Web服務ASP.NET

2024-12-05 08:14:41

2009-12-02 09:07:45

ASP.NET 4.0

2009-08-03 14:22:33

什么是ASP.NET

2009-07-28 17:17:19

ASP.NET概述

2009-07-22 17:45:35

ASP.NET教程

2009-07-23 14:25:03

ASP.NET 2.0

2009-07-28 14:10:14

2009-07-27 10:35:33

TypeConvertASP.NET

2009-07-29 11:19:03

JavaScriptASP.NET

2009-07-29 14:52:12

IScriptContASP.NET

2009-07-29 16:33:28

GreeterLogiASP.NET
點贊
收藏

51CTO技術棧公眾號