Ticket Q366124
Visible to All Users

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

created 13 years ago

Hello DevExpress,
I have a question which was discussed some times, but I got no answer so far which is practical.
In an ASPxGridView I need to hide the delete and edit command buttons conditionally.
In some examples you recommend the CommandButtonInitialze event.
There are several examples which demonstrate to handle the buttons visibility on oddRow condition.

But this is not practical for me, as I need to set the condition on a fields value in the particular gridrow.
For example: in my grid I have a column "processed". In all rows where Processed is true, I want hide the commanbutton,
when false the show it.
My question: How can I get the value of the column in the row inside the CommandButtonInitialize Event?
Thank you
Regards
Juergen

Answers approved by DevExpress Support

created 13 years ago (modified 12 years ago)

Hello Juergen,
Thank you for contacting us.
>>
Absolutely. Please use the E3028 - ASPxGridView - How to specify the CommandButtons’ and Custom CommandButtons’ properties based on any custom criteria Code Central example as a starting point.
It illustrates how to accomplish this task based on a particular DataRow's values:

C#
protected void ASPxGridViewInstance_CommandButtonInitialize(object sender, ASPxGridViewCommandButtonEventArgs e) { e.Visible = CommandButtonVisibleCriteria((ASPxGridView)sender, e.VisibleIndex); } private bool CommandButtonVisibleCriteria(ASPxGridView grid, int visibleIndex) { if (visibleIndex == -1) return false; bool processedValue = Convert.ToBoolean(grid.GetRowValues(visibleIndex, "processed")); return processedValue == true; }

Thanks,
Mike

    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.