Возникли проблемы при попытке получить строку объекта ASP.NET DataGrid - PullRequest
0 голосов
/ 29 марта 2011

Итак, у меня есть ASP.NET DataGrid, и в SomeName_ItemBound я пытаюсь установить видимость строки, если выполняются определенные условия. Тем не менее, я не могу найти способ получить строку.

Как выбрать текущую строку в:

SomeName_ItemBound(object sender, DataGridItemEventArgs e)

1 Ответ

1 голос
/ 29 марта 2011
  • DataGrid - это старый элемент управления, который вы должны использовать GridView, я думаю, вы уже используете GridView.
  • Вы можете получить текущую строку e.Item внутри вашего события ItemBound

как

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;
     }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...