Hi guys,
I have a Gridview wich is grouped by a column.
Design
On the Grid ItemDataBound event I delete all the controls from the Group template and add a label and image
This works perfectly when loaded, but when I click on a Grid Arrow to expand a Parent/Child, my added controls are removed and the ones in the design appears.
Any idea if there is a better solution ?
Thanks.
I have a Gridview wich is grouped by a column.
Design
<
GroupByExpressions
>
<
telerik:GridGroupByExpression
>
<
SelectFields
>
<
telerik:GridGroupByField
FieldAlias
=
"TL"
FieldName
=
"TargetLanguageCode"
FormatString
=
"{0:D}"
HeaderValueSeparator
=
": "
HeaderText
=
""
>
</
telerik:GridGroupByField
>
<
telerik:GridGroupByField
FieldAlias
=
"Flag"
FieldName
=
"FlagIcon"
FormatString
=
"{0:D}"
HeaderValueSeparator
=
": "
HeaderText
=
""
>
</
telerik:GridGroupByField
>
</
SelectFields
>
<
GroupByFields
>
<
telerik:GridGroupByField
FieldName
=
"TargetLanguageID"
SortOrder
=
"Descending"
></
telerik:GridGroupByField
>
<
telerik:GridGroupByField
FieldName
=
"FlagIcon"
></
telerik:GridGroupByField
>
</
GroupByFields
>
</
telerik:GridGroupByExpression
>
</
GroupByExpressions
>
On the Grid ItemDataBound event I delete all the controls from the Group template and add a label and image
protected
void
gridGeneratePackages_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridGroupHeaderItem)
{
GridGroupHeaderItem item = e.Item
as
GridGroupHeaderItem;
Image img =
new
Image();
img.ImageUrl = ((DataRowView)e.Item.DataItem)[1].ToString();
img.Width = 16;
img.Height = 12;
Label lbl =
new
Label();
lbl.Text = ((DataRowView)e.Item.DataItem)[0].ToString(); ;
lbl.Style.Add(
"margin-left"
,
"3px"
);
item.DataCell.Controls.Clear();
item.DataCell.Controls.Add(img);
item.DataCell.Controls.Add(lbl);
}
}
This works perfectly when loaded, but when I click on a Grid Arrow to expand a Parent/Child, my added controls are removed and the ones in the design appears.
Any idea if there is a better solution ?
Thanks.