2013-12-16 59 views
0

如何獲取aspxGridView的HtmlCommandCellPrepared事件中的數據單元值?如何在aspxGridView中獲取DataCell值?

我有一個名爲Issue的數據列,如果該列中的文本是RESOLVED那麼我希望刪除按鈕在​​中可見,否則刪除按鈕將不可見。

回答

1

我建議你去通過ASPxGridView - Hide/Show Custom Command Button/ASPxGridView.CustomButtonInitialize

你可以如下做到這一點:

protected void ASPxGridView1_CommandButtonInitialize(object sender, ASPxGridViewCommandButtonEventArgs e) { 
    if (e.VisibleIndex == -1) return; 

    switch (e.ButtonType) { 
     case ColumnCommandButtonType.Edit: 
      e.Visible = EditButtonVisibleCriteria((ASPxGridView)sender, e.VisibleIndex); 
      break; 
     case ColumnCommandButtonType.Delete: 
      e.Visible = DeleteButtonVisibleCriteria((ASPxGridView)sender, e.VisibleIndex); 
      break; 
    } 
} 

private bool DeleteButtonVisibleCriteria(ASPxGridView grid, int visibleIndex) { 
    object row = grid.GetRow(visibleIndex); 
    return ((DataRowView)row)["ProductName"].ToString().Contains("b"); 
} 

參見本:
ASPxGridView - How to specify the CommandButtons’ and Custom CommandButtons’ properties based on any custom criteria

+0

看起來不錯。謝謝。 – sms247

相關問題