偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

如何在DataBound事件中編碼確定數(shù)據(jù)的值

開發(fā) 后端
本文簡(jiǎn)單介紹了如何在DataBound事件中編碼確定數(shù)據(jù)的值。

為了將那些UnitPrice高于$75.00的產(chǎn)品用粗體,italic字體顯示出來,我們首先需要編碼確定UnitPrice的值,對(duì)于DetailsView我們可以通過DataBound事件完成. 我們選擇DetailsView并查看屬性視圖(F4位快捷鍵), 如果沒有顯示,則選擇 View(視圖)

Property Window(屬性窗口), 在確保您選擇了DetailsView的情況下雙擊DataBound事件或者輸入您要?jiǎng)?chuàng)建的事件名

為DataBound事件創(chuàng)建一個(gè)事件處理 

DataBound: 為DataBound事件創(chuàng)建一個(gè)事件處理

代碼中將會(huì)自動(dòng)生成以下代碼

  1. protected void ExpensiveProductsPriceInBoldItalic_DataBound(object sender, EventArgs e)  
  2.  
  3.    {  
  4.  
  5.  
  6.  
  7.    }  

我們可以通過DataItem屬性來設(shè)置DetailsView的綁定項(xiàng)(一些強(qiáng)類型的數(shù)據(jù)行(DataRow)組成的強(qiáng)類型的數(shù)據(jù)表(DataTable)), 當(dāng)數(shù)據(jù)表(DataTable)綁定到DetailsView時(shí),數(shù)據(jù)表的***行將被自動(dòng)綁定到DetailsView的DataItem屬性,而DataItem屬性中包含有DataRowView (Object類型),我們可以通過DataRowView來訪問一個(gè)ProductsRow 的DataRow實(shí)例,還可以檢測(cè)Object的值來確定ProductsRow實(shí)例是否存在

下面的代碼描述如何確定UnitPrice是否綁定到DetailsView并且高于$75.00

  1. protected void ExpensiveProductsPriceInBoldItalic_DataBound(object sender, EventArgs e)  
  2.  
  3. {  
  4.  
  5.     // Get the ProductsRow object from the DataItem property...  
  6.  
  7.     Northwind.ProductsRow product = (Northwind.ProductsRow)((System.Data.DataRowView) ExpensiveProductsPriceInBoldItalic.DataItem).Row;  
  8.  
  9.     if (!product.IsUnitPriceNull() && product.UnitPrice > 75m)  
  10.  
  11.     {  
  12.  
  13.         // TODO: Make the UnitPrice text bold and italic  
  14.  
  15.     }  
  16.  
  17. }  
  18.  

注意: 當(dāng)UnitPrice在數(shù)據(jù)庫的值為空,我們?cè)诮壎ǖ絇roductsRow’s UnitPrice屬性之前檢查確定他是否為空,這很重要因?yàn)槲覀兛梢酝ㄟ^檢查這個(gè)屬性來拋出一個(gè)強(qiáng)類型的異常 StrongTypingException exception.

【編輯推薦】

  1. ASP.NET 2.0數(shù)據(jù)教程:添加和配置ObjectDataSource控件
  2. ASP.NET 2.0數(shù)據(jù)教程:給每個(gè)部分添加Default.aspx頁面
  3. ASP.NET 2.0數(shù)據(jù)教程:添加breadcrumb導(dǎo)航
  4. ASP.NET 2.0數(shù)據(jù)教程:SiteMapDataSource控件
  5. ASP.NET 2.0數(shù)據(jù)教程:添加站點(diǎn)地圖
責(zé)任編輯:book05 來源: 博客堂
相關(guān)推薦

2009-07-27 16:56:05

DataBound

2009-07-28 03:43:00

RowDataBoun

2013-05-15 15:30:02

數(shù)據(jù)中心綜合布線

2016-01-22 11:05:07

2024-12-26 10:28:44

2017-12-27 14:22:07

數(shù)據(jù)中心負(fù)載成本

2015-07-20 11:12:43

數(shù)據(jù)中心數(shù)據(jù)中心建設(shè)

2022-11-15 20:48:41

Linux

2023-12-07 19:00:25

數(shù)據(jù)科學(xué)機(jī)器學(xué)習(xí)數(shù)據(jù)可視化

2021-05-12 14:34:08

大數(shù)據(jù)數(shù)據(jù)標(biāo)準(zhǔn)技術(shù)

2023-01-10 08:47:44

CIOIT領(lǐng)導(dǎo)者

2009-06-14 17:53:25

ibmdwWebSphere

2022-04-13 09:30:00

C++二分圖圖著色

2022-05-27 12:09:44

FedoraLinux

2010-05-07 15:58:49

數(shù)據(jù)泄漏企業(yè)安全

2011-03-21 12:41:41

JavaScript

2025-01-21 15:20:14

2011-04-06 13:40:48

Delphi

2024-09-26 21:49:19

2024-09-24 14:58:39

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)