ASPxGridView.DetailRowGetButtonVisibility Event
Enables you to hide/show expand buttons displayed within individual data rows.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.2.dll
Declaration
Event Data
The DetailRowGetButtonVisibility event's data class is ASPxGridViewDetailRowButtonEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
ButtonState | Gets or sets the button’s state. |
IsExpanded | Gets whether the processed data row is expanded. |
KeyValue | Gets an object that uniquely identifies the data row. Inherited from ASPxGridViewItemEventArgs. |
VisibleIndex | Gets the visible index of the data row. Inherited from ASPxGridViewItemEventArgs. |
Remarks
The DetailRowGetButtonVisibility event is raised for each data row, and allows you to hide/show their expand buttons. You can handle it to hide expand buttons for data rows whose details have no data.
Use the ASPxGridViewDetailRowButtonEventArgs.ButtonState property to specify the button’s state. The event parameter’s ASPxGridViewItemEventArgs.KeyValue property identifies the processed row. To obtain whether the processed row is exapanded, use the ASPxGridViewDetailRowButtonEventArgs.IsExpanded property.
Note
The DetailRowGetButtonVisibility event isn’t raised if the ASPxGridViewDetailSettings.ShowDetailButtons option is disabled.
Example
This example uses the server-side DetailRowGetButtonVisibility event to hide the detail button for "empty" detail rows.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.v13.2, Version=13.2.13.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v13.2, Version=13.2.13.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>How to hide the detail button if the detail grid is empty</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
</div>
<dx:ASPxGridView ID="mainGrid" runat="server" AutoGenerateColumns="False" DataSourceID="masterDataSource"
KeyFieldName="CategoryID" OnDataBinding="masterGrid_DataBinding" OnDetailRowGetButtonVisibility="masterGrid_DetailRowGetButtonVisibility">
<Templates>
<DetailRow>
<dx:ASPxGridView ID="detailGrid" runat="server" AutoGenerateColumns="False" DataSourceID="dsDetail"
KeyFieldName="ProductID" OnBeforePerformDataSelect="detailGrid_BeforePerformDataSelect"
Width="100%">
<Styles>
<DetailRow HorizontalAlign="Justify">
</DetailRow>
</Styles>
<Columns>
<dx:GridViewDataTextColumn FieldName="ProductID" ReadOnly="True" VisibleIndex="0">
<EditFormSettings Visible="False" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="1">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="2">
</dx:GridViewDataTextColumn>
</Columns>
</dx:ASPxGridView>
</DetailRow>
</Templates>
<Columns>
<dx:GridViewDataTextColumn FieldName="CategoryID" ReadOnly="True" VisibleIndex="0">
<EditFormSettings Visible="False" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="CategoryName" VisibleIndex="1">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Description" VisibleIndex="2">
</dx:GridViewDataTextColumn>
</Columns>
<SettingsDetail ShowDetailRow="True" />
</dx:ASPxGridView>
<asp:AccessDataSource ID="dsDetail" runat="server" DataFile="~/App_Data/nwind.mdb"
SelectCommand="SELECT [ProductID], [ProductName], [CategoryID], [UnitPrice] FROM [Products] WHERE ([CategoryID] = ?)">
<SelectParameters>
<asp:SessionParameter DefaultValue="CategoryID" Name="CategoryID" SessionField="CategoryID"
Type="Int32" />
</SelectParameters>
</asp:AccessDataSource>
<asp:AccessDataSource ID="masterDataSource" runat="server" DataFile="~/App_Data/nwind.mdb"
SelectCommand="SELECT * FROM [Categories]"></asp:AccessDataSource>
</form>
</body>
</html>