Ticket Q438657
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

ASPxGridView - How to use the CommandButtonInitialize event and get row values

ASPxGridView - Hide / Show Custom Command Button / ASPxGridView.CustomButtonInitialize

created 12 years ago

Hi

Need help with a custom command button I would like to show/hide it according to grid data.
for each row whenever the data in the cell "status" == 'pending" show button else hide button.

C#
protected void grid_HtmlCommandCellPrepared(object sender, ASPxGridViewTableCommandCellEventArgs e) { if (e.CommandCellType == GridViewTableCommandCellType.Data && e.CommandColumn.Name == "Goedkeuren") { var rowdata = ((ASPxGridView)sender).GetRowValues( e.VisibleIndex, FacturatiebonControler.FacturatiebonStatusColumnName); if (rowdata != null) { string status = rowdata.ToStringValue(); if (status == "Pending") e.CommandColumn.CustomButtons[0].Visibility = GridViewCustomButtonVisibility.AllDataRows; else e.CommandColumn.CustomButtons[0].Visibility = GridViewCustomButtonVisibility.Invisible; } } }

My code now but that does not work don't know what I'm doing wrong?

Answers

created 12 years ago (modified 12 years ago)

Hello Steve,
It is necessary to use the ASPxGridView.CustomButtonInitialize event for this purpose.
Take a look at the E3028 - ASPxGridView - How to specify the CommandButtons’ and Custom CommandButtons’ properties based on any custom criteria Code Central example to see this technique.

    Show previous comments (11)

      Hello,
      This issue sounds strange. By default, the AutoFilterRow contains editors, which are automatically created according to the column type. Please make sure that you are not specifying custom AutoFilterRow cell content by handling the ASPxGridView.AutoFilterCellEditorCreate/ASPxGridView.AutoFilterCellEditorInitialize.
      However, it seems that this is another issue. Would you please create a separate ticket in our Support Center and describe this situation in greater detail?
      A standalone ASP.NET WebSite/WebApplication (i.e., not a VisualWebPart) that mimics this situation would be helpful.

        Hi
        I found the issue with the filterrow I added:
         if (e.CellType == GridViewTableCommandCellType.Filter) return;
        after debugging the code I found that
          if (e.VisibleIndex < 0) return; was not enough because the filter row allso has a VisibleIndex of 0;

          Hello,
          Thank you for informing us that the problem has been resolved.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.