<
telerik:GridTemplateColumn
Datafield
=
"customer_cd"
HeaderStyle-Width
=
"20%"
HeaderText
=
"Customer"
ItemStyle-HorizontalAlign
=
"Center"
SortExpression
=
"end_dt"
ItemStyle-VerticalAlign
=
"Middle"
UniqueName
=
"customer_cd"
>
<
ItemTemplate
>
<
table
>
<
colgroup
>
<
col
/>
</
colgroup
>
<
tr
>
<
td
>
<
asp:HyperLink
ID
=
"hlCustomerCd"
runat
=
"server"
ImageUrl='<%# string.Format("icons/{0}.gif",Eval("customer_cd")) %>' NavigateUrl='<%# string.Format("customer.aspx?org_cd={0}&cust_id={1}", org_cd, Eval("customer_id")) %>'
Text='<%# Eval("customer_nm").ToString() %>' />
<
br
/>
<
asp:Label
ID
=
"lblCustomerCd"
runat
=
"server"
Text='<%# Eval("customer_nm").ToString() %>' Font-Size="X-Small" />
<
br
/>
<
asp:HyperLink
ID
=
"hlAgreementNo"
runat
=
"server"
NavigateUrl=' <%# string.Format("agreement.aspx?org_cd={0}&cust_id={1}&agmt_id={2}", org_cd, Eval("customer_id"), Eval("agreement_id"))%>' Text='<%# "Agreement:" + Eval("customer_purchase_order_no") %>' ForeColor="#2dabc1" />
</
td
>
</
tr
>
</
table
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
protected
void
rgSite_PreRender(
object
sender, EventArgs e)
{
//The Row Index is the Row above the bottom row, walk up the Grid
for
(
int
rowIndex = rgSite.Items.Count - 2; rowIndex >= 0; rowIndex += -1)
{
//The Current Row is the row index
GridDataItem row = rgSite.Items[rowIndex];
//The Previous Row is one below it
GridDataItem previousRow = rgSite.Items[rowIndex + 1];
//Grab the ItemTemplate Text values from the Hyperlink of the current and previous row and compare them.
if
((row[
"customer_cd"
].FindControl(
"hlCustomerCd"
)
as
HyperLink).Text == (previousRow[
"customer_cd"
].FindControl(
"hlCustomerCd"
)
as
HyperLink).Text)
{
//The Top Row Absorbs the previous Rowspan
row[
"customer_cd"
].RowSpan = previousRow[
"customer_cd"
].RowSpan < 2 ? 2 : previousRow[
"customer_cd"
].RowSpan + 1;
//The previous row then goes away.
previousRow[
"customer_cd"
].Visible =
false
;
}
}
}
This is sort of a minor adjustment to the solution given in another forum to allow for the same thing in a Grid Template Column.