在DataBound事件處理中編碼確定數(shù)據(jù)的值
作者:xwang
本文簡單介紹了如何在DataBound 事件處理中編碼確定數(shù)據(jù)的值。
當FormView的標記完成后,下一步就是確定UnitsInStock的值是否小于等于10,這里和在DetailView中類似,先創(chuàng)建DataBound事件
圖: 創(chuàng)建 DataBound 事件處理
在事件中聲明FormView的DataItem屬性到ProductsRow實例中,確定UnitsInPrice的值并將對應的值用紅色字體顯示
- protected void LowStockedProductsInRed_DataBound(object sender, EventArgs e)
- {
- // Get the ProductsRow object from the DataItem property...
- Northwind.ProductsRow product = (Northwind.ProductsRow)((System.Data.DataRowView)LowStockedProductsInRed.DataItem).Row;
- if (!product.IsUnitsInStockNull() && product.UnitsInStock < = 10)
- {
- // TODO: Make the UnitsInStockLabel’s text red
- }
- }
這樣就實現(xiàn)了在DataBound事件處理中編碼確定數(shù)據(jù)的值。
【編輯推薦】
責任編輯:book05
來源:
博客堂