如何在aspxGridView中获取DataCell值?

时间:2013-12-16 04:43:03

标签: devexpress aspxgridview

如何在aspxGridView的HtmlCommandCellPrepared事件中获取数据单元格值?

我的数据列名为Issue,如果该列中的文字为RESOLVED,那么我希望删除按钮在commandcolumn其他删除按钮中可见。

1 个答案:

答案 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");
}

参考:
ASPxGridView - How to specify the CommandButtons’ and Custom CommandButtons’ properties based on any custom criteria