如何在aspxGridView的HtmlCommandCellPrepared事件中获取数据单元格值?
我的数据列名为Issue
,如果该列中的文字为RESOLVED
,那么我希望删除按钮在commandcolumn
其他删除按钮中可见。
答案 0 :(得分: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");
}