prevynjeftha
prevynjeftha

Reputation: 33

DevXpress grid view: change GridViewCommandColumnCustomButton Image-Url

all.

I have a DevXpress gridview, and each row contains 2 custom image buttons: edit and cancel.

In the grid is a specific column that will determine whether the image buttons get displayed or not. If the column contains a 5, then don't show the buttons. Otherwise always show the buttons.

How can I access the Image-Url property from the code behind or will it have to be through the JavaScript?

Code extract re custom button definition:

<dxwgv:GridViewCommandColumn ButtonType="Image" Caption="Edit" AllowDragDrop="False" >
  <CustomButtons>
    <dxwgv:GridViewCommandColumnCustomButton ID="EditButton" Text="Click to edit" Image-Url="~/Images/16x16/edit.png" Visibility="AllDataRows" Image-AlternateText="Edit" />
  </CustomButtons>
</dxwgv:GridViewCommandColumn>
<dxwgv:GridViewCommandColumn ButtonType="Image" Caption="Cancel" AllowDragDrop="False">
  <CustomButtons>
    <dxwgv:GridViewCommandColumnCustomButton ID="CancelButton" Text="Click to cancel" Image-Url="~/Images/16x16/delete2.png" Visibility="AllDataRows" Image-AlternateText="Cancel" />
  </CustomButtons>
</dxwgv:GridViewCommandColumn>

Any ideas would be appreciated. Really not have much joy with DevXpress.

Thanks!

Upvotes: 2

Views: 2935

Answers (1)

dcreight
dcreight

Reputation: 641

Here is one possibility:

        protected void ASPxGridView1_CustomButtonInitialize(object sender, ASPxGridViewCustomButtonEventArgs e)
    {
        int i = Convert.ToInt32((sender as ASPxGridView).GetMasterRowKeyValue());
        if (i == 5)
            e.Image.Url = "images/checkmark.gif";
        else
            e.Image.Url = "images/trash.gif";
    }

Then of course in the ASPX file you would need to add:

oncustombuttoninitialize="ASPxGridView1_CustomButtonInitialize"

Upvotes: 1

Related Questions