簡體   English   中英

嘗試獲取ASP.NET DataGrid對象的行時遇到問題

[英]Having problems attempting to grab the row of a ASP.NET DataGrid Object

因此,我有一個ASP.NET DataGrid,在SomeName_ItemBound中,如果滿足某些條件,我將嘗試設置行的可見性。 但是,我似乎找不到找到行的方法。

如何在以下位置選擇當前行:

SomeName_ItemBound(object sender, DataGridItemEventArgs e)
  • DataGrid是您應該使用GridView的舊控件,我想您必須已經使用GridView了。
  • 您可以通過ItemBound事件中的e.Item獲取當前行

喜歡

protected void SomeName_ItemBound(Object sender, DataGridItemEventArgs e) 
{
     // Use the ItemDataBound event to customize the DataGrid control. 
     // The ItemDataBound event allows you to access the data before 
     // the item is displayed in the control. In this example, the 
     // ItemDataBound event is used to format the items in the 
     // CurrencyColumn in currency format.
     if((e.Item.ItemType == ListItemType.Item) || 
         (e.Item.ItemType == ListItemType.AlternatingItem))
     {
         // e.Item // is your current row
         e.Item.Visible = false;
     }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM