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

通過(guò)e.Row實(shí)現(xiàn)GridViewRow訪問(wèn)單元格

開(kāi)發(fā) 后端
本文簡(jiǎn)單介紹了如何通過(guò)e.Row實(shí)現(xiàn)GridViewRow訪問(wèn)單元格。

我們需要訪問(wèn)GridViewID.Rows[index]來(lái)訪問(wèn)index對(duì)應(yīng)的那一行,GridViewID.Rows[index].Cells[index]來(lái)訪問(wèn)某一單元格.然而當(dāng)RowDataBound事件觸發(fā)時(shí),GridViewRow卻沒(méi)有添加到Rows集合中, 因此我們不能在RowDataBound事件處理中通過(guò)當(dāng)前GridViewRow實(shí)例

取而代之,我們可以通過(guò)e.Row來(lái)訪問(wèn)。為了高亮某一行我們用下面的代碼

  1. e.Row.BackColor = System.Drawing.Color.Yellow;  

我們還可以通過(guò)cSSClass取得同樣的效果(推薦)   

  1. protected void HighlightCheapProducts_RowDataBound(object sender, GridViewRowEventArgs e)  
  2.  
  3.     {  
  4.  
  5.         // Make sure we are working with a DataRow  
  6.  
  7.         if (e.Row.RowType == DataControlRowType.DataRow)  
  8.  
  9.         {  
  10.  
  11.             // Get the ProductsRow object from the DataItem property...  
  12.  
  13.             Northwind.ProductsRow product = (Northwind.ProductsRow)((System.Data.DataRowView)e.Row.DataItem).Row;  
  14.  
  15.             if (!product.IsUnitPriceNull() && product.UnitPrice <  10m)  
  16.  
  17.             {  
  18.  
  19.                 e.Row.CssClass = "AffordablePriceEmphasis";  
  20.  
  21.             }  
  22.  
  23.         }  
  24.  
  25.     }  
  26.  

所需要的行用高亮黃色顯示 

GridViewRow: 所需要的行用高亮黃色顯示

【編輯推薦】

  1. ASP.NET 2.0數(shù)據(jù)教程:SelectMethod屬性的使用
  2. ASP.NET 2.0數(shù)據(jù)教程:在業(yè)務(wù)邏輯層添加方法
  3. ASP.NET 2.0數(shù)據(jù)教程:為T(mén)ableAdapter添加方法
  4. ASP.NET 2.0數(shù)據(jù)教程:使用一個(gè)硬編碼參數(shù)值
  5. ASP.NET 2.0數(shù)據(jù)教程:綁定到ObjectDataSource
責(zé)任編輯:book05 來(lái)源: 博客堂
相關(guān)推薦

2009-08-07 17:54:41

C#單元格數(shù)據(jù)

2021-08-13 11:10:32

OpenPyXLExcelPython

2013-06-20 11:10:24

iOS開(kāi)發(fā)UItableView單元格背景漸變

2015-01-15 16:34:31

iOS源碼單元格

2009-07-27 16:46:07

DetailsView

2010-08-11 16:41:30

Flex DataGr

2010-04-27 11:11:06

Oracle修改JTa

2010-08-11 16:30:49

Flex DataGr

2021-09-09 08:58:32

Excel數(shù)據(jù)處理函數(shù)

2020-11-20 10:52:54

Antd表格日程

2020-02-19 14:55:20

開(kāi)發(fā)技能代碼

2021-05-10 10:50:53

NginxIPLinux

2024-05-28 07:53:23

2010-08-26 10:42:18

CSStr td

2009-07-02 14:42:55

ExtJS Grid

2024-02-26 00:00:01

?win32WindowsCOM

2011-06-15 10:49:26

Qt QTableItem

2011-06-15 12:58:05

Qt QTableWidg

2022-08-01 08:02:25

單元格可視化語(yǔ)法

2009-08-07 17:56:07

DataGrid的樣式
點(diǎn)贊
收藏

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