Question

How to get a data cell value in HtmlCommandCellPrepared event of aspxGridView?

I have datacolumn named Issue if text in that column is RESOLVED then I want the delete button to be visible in the commandcolumn else delete button will be invisible.

Was it helpful?

Solution

I suggest you to go through ASPxGridView - Hide / Show Custom Command Button / ASPxGridView.CustomButtonInitialize

You can do this as below:

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top