GridViewTemplates.GroupRowContent Property
Gets or sets a template for displaying the content of group rows.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v20.2.dll
NuGet Package: DevExpress.Web
Declaration
Property Value
Type | Default | Description |
---|---|---|
ITemplate | *null* | An object that implements the ITemplate interface. |
Remarks
Note
Once a template defined via the GroupRowContent property is created within a grid control, it is instantiated within a container object of the GridViewGroupRowTemplateContainer type. This container object exposes a set of specific properties to which the template’s child controls can be bound.
Example
This example demonstrates how to expand/collapse grid groups on selecting/unselecting ASPxCheckBox.First, place ASPxCheckBox and ASPxLabel into the Grid.Templates.GroupRowContent
template.
Second, set the ASPxCheckBox.Checked property and the client-side CheckedChanged event in the ASPxCheckBox.Init event handler.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v10.1, Version=10.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v10.1, Version=10.1.4.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 use the ASPxCheckBox for expand and collapse ASPxGridView groups</title>
<script type="text/javascript">
function ExpandCollapse(sender, index) {
if (sender.GetChecked())
grid.ExpandRow(index);
else
grid.CollapseRow(index);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<dx:ASPxGridView ID="ASPxGridView1" runat="server" ClientInstanceName="grid" AutoGenerateColumns="False" DataSourceID="AccessDataSource1"
KeyFieldName="ProductID">
<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="CategoryID" VisibleIndex="2" GroupIndex="0" SortIndex="0" SortOrder="Ascending">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="3">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="UnitsInStock" VisibleIndex="4">
</dx:GridViewDataTextColumn>
</Columns>
<Templates>
<GroupRowContent>
<dx:ASPxCheckBox ID="ASPxCheckBox1" runat="server" OnInit="ASPxCheckBox1_Init">
</dx:ASPxCheckBox>
<%# Container.GroupText + Container.KeyValue%>
</GroupRowContent>
</Templates>
<Settings ShowGroupButtons="False" ShowGroupPanel="True" />
</dx:ASPxGridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/nwind.mdb"
SelectCommand="SELECT [ProductID], [ProductName], [CategoryID], [UnitPrice], [UnitsInStock] FROM [Products]">
</asp:AccessDataSource>
</div>
</form>
</body>
</html>