
<telerik:GridTemplateColumn UniqueName="Template1" GroupByExpression = "Febrero"> |
<ItemTemplate> |
<asp:HyperLink ID="targetControl" runat="server" NavigateUrl="#" Text='<%# Eval("Febrero") %>'></asp:HyperLink> |
</ItemTemplate> |
<FooterTemplate> |
<asp:HyperLink runat="server" ID="TextBox2"> |
</asp:HyperLink> |
<telerik:GridGroupPanel> |
<PanelItemsStyle Height="200" BackColor="Aquamarine" /> |
</telerik:GridGroupPanel> |
</FooterTemplate> |
</telerik:GridTemplateColumn> |
protected void tk_Grid_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridDataItem) |
{ |
GridDataItem dataItem = (GridDataItem)e.Item; |
sum += double.Parse((dataItem["Template1"].FindControl("targetControl") as HyperLink).Text); |
} |
else if (e.Item is GridFooterItem) |
{ |
GridFooterItem footer = (GridFooterItem)e.Item; |
(footer["Template1"].FindControl("TextBox2") as HyperLink).Text = sum.ToString(); |
FooterTotals = (footer["Template1"].FindControl("TextBox2") as HyperLink).Text; |
} |
} |
9 Answers, 1 is accepted
Your implemenation seems correct. Can you please verify (debugging your code) that the logic in the ItemDataBound handler gets executed as expected. Additionally, confirm that the sum variable has global scope in the code behind as in the corresponding paragraph of this help topic.
You may also be happy to know that we will introduce declarative aggregates for GridTemplateColumns (by their DataField property setting) with the Q3 2009 release of RadGrid, expected next week.
Best regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

finally i can fix it, the only i need to put groupfootertotals and switch each value into hyperlinks is:
else if (e.Item is GridGroupFooterItem) { GridGroupFooterItem gridfooteritem = e.Item as GridGroupFooterItem; gridfooteritem["Apertura"].Text = "<a class=links href=" + sumape.ToString() + ">" + sumape.ToString() + "</a>"; |
then when i need to call a popup window i can't doit from an asp:hyperlink so i set asp:hyperlink visible = false (just use it for the itemdatabound event) and put an <a href.... filled with the same data , what do you think ? thanks Sebastian and all the telerik team for your efforts, this is a great components suite and im waiting for Q3.
<telerik:GridTemplateColumn UniqueName="Enero" ItemStyle-HorizontalAlign="Right" HeaderText="Ene"> |
<HeaderTemplate> |
<a href="#" onclick="AbreVentana('frmEEFFMensual.aspx?Periodo=ENERO&MesID=1','Balance');">Ene</a> |
</HeaderTemplate> |
<HeaderStyle HorizontalAlign="Right" /> |
<ItemTemplate> |
<a href="#" class="links" onclick="AbreVentana('frmAnexoBalance.aspx?Periodo=ENERO&MesID=1','Balance');"><%# Eval("Enero") %></a> |
<asp:HyperLink ID="lnkEnero" Visible="false" CssClass="links" Target="_blank" runat="server" NavigateUrl="frmAnexoBalance.aspx?Periodo=ENERO&MesID=1" Text='<%# Eval("Enero") %>'></asp:HyperLink> |
</ItemTemplate> |
<FooterStyle HorizontalAlign="Right" /> |
<FooterTemplate> |
<asp:HyperLink runat="server" ID="SumEnero" NavigateUrl="#" Text="" CssClass="linkstotal"> |
</asp:HyperLink> |
</FooterTemplate> |
</telerik:GridTemplateColumn> |
Best Regards
Gino

Consider the javascript solution presented on this integration example:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandinput/defaultcs.aspx?product=grid
Examine the description and code snippets for more info.
Best,
Sebastian
the Telerik team

Here is the javascript:
function Variance(sender, args)
{
var rdgrid = $find("<%=RadGrid1.ClientID %>");
var cell = sender.get_element().parentNode.parentNode;
var index = cell.parentNode.rowIndex;
var MasterTable = rdgrid.get_masterTableView();
var row = MasterTable.get_dataItems()[index - 2]; //getting row
var tbxAdopted = row.findControl("tbxAdopted").get_value(); //getting value of TextBox 'tbxAdopted'
var tbxReq = row.findControl("tbxReq").get_value();
var Variance = tbxReq - tbxAdopted;
var tbxVariance = MasterTable.get_dataItems()[index - 2].findControl("tbxVar");
tbxVariance.set_value(Variance);
}
function RequestedTotal(sender) {
sumInput = sender;
tempValue = sumInput.get_value() - sender.get_value();
sumInput.set_value(tempValue + sender.get_value());
}
function VarianceTotal(sender, args) {
sumInput = sender;
tempValue = sumInput.get_value() - sender.get_value();
sumInput.set_value(tempValue + sender.get_value());
}
Here is my radGrid:
'Format Code Block'
<telerik:RadGrid ID="RadGrid1" runat="server" ShowFooter="true" AutoGenerateColumns="False"
AllowSorting="true" EnableEmbeddedSkins="False" Skin="GridCustom" Width="1000px"
EnableLinqExpressions="false" OnItemDataBound="RadGrid1_ItemDataBound" OnNeedDataSource="RadGrid1_NeedDataSource1"
OnItemCreated="RadGrid1_ItemCreated" OnUpdateCommand="RadGrid1_UpdateCommand"
OnItemCommand="RadGrid1_ItemCommand" OnColumnCreated="RadGrid1_ColumnCreated"
OnInsertCommand="RadGrid1_InsertCommand" OnCancelCommand="RadGrid1_CancelCommand"
OnPreRender="RadGrid1_PreRender">
<MasterTableView DataKeyNames="Account" EditMode="InPlace" CommandItemDisplay="TopAndBottom"
InsertItemDisplay="Top" AllowAutomaticInserts="false" ShowGroupFooter="true">
<Columns>
<telerik:GridEditCommandColumn ButtonType="PushButton" Visible="false">
<ItemStyle HorizontalAlign="Center" Width="100px" CssClass="BorderLeft BorderRight BorderBottom" />
<FooterStyle CssClass="BorderLeft BorderRight BorderBottom" />
</telerik:GridEditCommandColumn>
<telerik:GridTemplateColumn DataField="LongAccount" HeaderStyle-HorizontalAlign="Center"
UniqueName="LongAccount" HeaderText="Account" ReadOnly="true" ShowSortIcon="false"
FooterText="Sub Total">
<ItemTemplate>
<asp:Label ID="lblAccount" runat="server" Text='<%#Bind("LongAccount") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<div style="width: 120px;">
</div>
<table cellpadding="0" cellspacing="0">
<tr>
<td style="width: 120px; padding-left: 0;">
<telerik:RadMaskedTextBox ID="mtbxAccount" runat="server" Text='<%# Bind("Account")%>' >
<ClientEvents OnValueChanged="onChange" />
</telerik:RadMaskedTextBox>
</td>
<td style="font-size: small; padding-left: 5px;">
<input id="Button1" type="button" value="Available Accounts" onclick="openWin(); return false;" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="mtbxAccount"
ErrorMessage="Required" runat="server">
</asp:RequiredFieldValidator>
</td>
</tr>
</table>
</EditItemTemplate>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Left" Width="100px" CssClass="BorderRight BorderLeft BorderBottom" />
<FooterStyle CssClass="BorderRight BorderLeft BorderBottom" />
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="Description" ReadOnly="true" UniqueName="Description"
HeaderText="Description" ShowSortIcon="false">
<ItemStyle HorizontalAlign="Left" Width="200px" CssClass="BorderRight BorderBottom" />
<FooterStyle CssClass="BorderRight BorderBottom" />
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn DataField="Adopted" ReadOnly="true" HeaderStyle-HorizontalAlign="Center"
UniqueName="Adopted" HeaderText="Adopted" ShowSortIcon="false" >
<ItemTemplate>
<telerik:RadNumericTextBox ID="tbxAdopted" Value='<%#Bind("Adopted") %>' CssClass="RightAlign" ReadOnly="true"
runat="server" Culture="English (United States)" Type="Number" NumberFormat-DecimalDigits="0"
Width="90px" MinValue="-999999" DataType="System.Int32" Enabled="false" DataFormatString="{0:N0}">
</telerik:RadNumericTextBox>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Right" Width="100px" CssClass="BorderRight BorderBottom" />
<FooterStyle CssClass="BorderRight BorderBottom" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="Requested" ReadOnly="true" HeaderStyle-HorizontalAlign="Center"
UniqueName="Requested" HeaderText="Requested" ShowSortIcon="false">
<EditItemTemplate>
<telerik:RadNumericTextBox ID="tbxRequested" DbValue='<%#Bind("Requested") %>' runat="server"
Culture="English (United States)" Type="Number" NumberFormat-DecimalDigits="0"
Width="90px" MinValue="0" DataType="System.Int32" >
</telerik:RadNumericTextBox>
</EditItemTemplate>
<ItemTemplate>
<telerik:RadNumericTextBox ID="tbxReq" Value='<%#Bind("Requested") %>' CssClass="RightAlign"
runat="server" Culture="English (United States)" Type="Number" NumberFormat-DecimalDigits="0"
Width="90px" MinValue="0" DataType="System.Int32" Enabled="false">
<ClientEvents OnValueChanged="Variance" />
</telerik:RadNumericTextBox>
</ItemTemplate>
<%-- <FooterTemplate>
<telerik:RadNumericTextBox ID="tbxVarRequested" runat="server" Type="Currency" ReadOnly="true" DataFormatString="{0:N0}">
<ClientEvents OnLoad="RequestedTotal" />
</telerik:RadNumericTextBox>
</FooterTemplate>--%>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Right" Width="100px" CssClass="BorderRight BorderBottom" />
<FooterStyle CssClass="BorderRight BorderBottom" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="Variance" ReadOnly="true" HeaderStyle-HorizontalAlign="Center"
UniqueName="Variance" HeaderText="Variance" ShowSortIcon="false" >
<ItemTemplate>
<telerik:RadNumericTextBox ID="tbxVar" Value='<%#Bind("Variance") %>' CssClass="RightAlign" ReadOnly="true"
runat="server" Culture="English (United States)" Type="Number" NumberFormat-DecimalDigits="0"
Width="90px" MinValue="-999999" DataType="System.Int32" Enabled="false" DataFormatString="{0:N0}">
<ClientEvents OnValueChanged="VarianceTotal" />
</telerik:RadNumericTextBox>
</ItemTemplate>
<%-- <FooterTemplate>
<telerik:RadNumericTextBox ID="tbxVarFooter" runat="server" Type="Currency" ReadOnly="true" DataFormatString="{0:N0}">
<ClientEvents OnLoad="VarianceTotal" />
</telerik:RadNumericTextBox>
</FooterTemplate>--%>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Right" Width="100px" CssClass="BorderRight BorderBottom" />
<FooterStyle CssClass="BorderRight BorderBottom" />
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="AcctType" Visible="false" ReadOnly="true" UniqueName="AcctType"
HeaderText="AcctType" ShowSortIcon="false">
<ItemStyle HorizontalAlign="Left" CssClass="BorderRight BorderBottom" />
<FooterStyle CssClass="BorderRight BorderBottom" />
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn DataField="Justification" UniqueName="Justification"
HeaderText="Justification" ShowSortIcon="false">
<EditItemTemplate>
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:TextBox ID="txtJustification" Text='<%#Bind("Justification") %>' runat="server"
Width="500px" TextMode="MultiLine" Rows="4" MaxLength="2000">
</asp:TextBox>
</td>
<td style="font-size: small; padding-left: 5px;">
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Maximum 800 characters"
ControlToValidate="txtJustification" EnableTheming="True" ValidationExpression="^[\s\S]{0,800}$"></asp:RegularExpressionValidator>
<asp:BulletedList ID="blistErrors" runat="server" ForeColor="Red" BulletStyle="Disc">
</asp:BulletedList>
</td>
</tr>
</table>
</EditItemTemplate>
<ItemTemplate>
<asp:TextBox ID="tbxJust" runat="server" TextMode="MultiLine" Rows="4" Width="360px"
MaxLength="2000" Text='<%#Bind("Justification") %>'></asp:TextBox>
<br />
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="Maximum 800 characters"
ControlToValidate="tbxJust" EnableTheming="True" ValidationExpression="^[\s\S]{0,800}$"></asp:RegularExpressionValidator>
<%--<asp:Label ID="lblJustification" runat="server" Text='<%#(Eval("Justification") == null || Eval("Justification") == "") ?" ":Eval("Justification") %>'></asp:Label>--%>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle CssClass="BorderRight BorderBottom" />
<FooterStyle CssClass="BorderRight BorderBottom" />
</telerik:GridTemplateColumn>
</Columns>
<EditFormSettings>
<FormTableItemStyle Wrap="false" Font-Bold="true" Font-Size="Small" />
<FormTableAlternatingItemStyle Wrap="false" Font-Bold="true" Font-Size="Small" />
<EditColumn ButtonType="PushButton" InsertText="Save" UpdateText="Save">
</EditColumn>
<FormMainTableStyle Width="1200px" />
<FormStyle BorderColor="Peru" BorderWidth="1px" BorderStyle="Solid" />
<FormTableButtonRowStyle HorizontalAlign="Center" Width="100%" />
</EditFormSettings>
<CommandItemTemplate>
<div style="margin: 2px 0 0 0; vertical-align: middle; text-align: left;">
<asp:Button ID="btnAddNew" runat="server" Text="Add New" Width="100px" CommandName="InitInsert" />
<asp:Button ID="btnSaveAll" runat="server" Text="Save All" Width="100px" CommandName="SaveAll" OnClientClick="return confirm('Please do not click the back button or navigate away from page until save is complete.');" />
<telerik:RadSpell ID="RadSpell1" runat="server" CssClass="RadSpellInline" Width="100px" AllowAddCustom="false" />
<asp:Button ID = "btnClear" runat ="server" Text="Clear" Width ="100px" CommandName="Clear" />
</div>
</CommandItemTemplate>
</MasterTableView>
<FilterMenu EnableEmbeddedSkins="False">
</FilterMenu>
</telerik:RadGrid>
Code behind c#:
else if (e.Item is GridFooterItem)
{
GridFooterItem item = (GridFooterItem)e.Item;
if (item != null)
{
//(item["Requested"].FindControl("tbxReqFooter") as RadNumericTextBox).Value = Double.Parse(_requestedTotal.ToString("N0"));
item["Requested"].Text = _requestedTotal.ToString("N0");
//(item["Variance"].FindControl("tbxVarFooter") as RadNumericTextBox).Value = Double.Parse(_requestedTotal.ToString("N0"));
item["Variance"].Text = _varianceTotal.ToString("N0");
item["Adopted"].Text = _adoptedTotal.ToString("N0");
if (Denton.Service.MoneyToDouble(item["Variance"].Text) > 0)
{
item["Variance"].ForeColor = System.Drawing.Color.Red;
}
}
}
}
I suggest you debug your javascript code to see whether the values are calculated accurately and set in the numeric textbox fields as expected. Also consider using your local version of the online demo as basis - its default installation location should be as follows:
C:\Program Files\Telerik\RadControls for ASP.NET AJAX QX 2010\Live Demos\Controls\Examples\Integration\GridAndInput (32 bit machine)
C:\Program Files (x86)\Telerik\RadControls for ASP.NET AJAX QX 2010\Live Demos\Controls\Examples\Integration\GridAndInput (64 bit machine)
Regards,
Sebastian
the Telerik team

<telerik:RadGrid ID="RadGridClientMandate" GridLines="None" runat="server" AutoGenerateColumns="False"
OnItemDataBound="drmandates_ItemDataBound" Skin="3iGrid" EnableEmbeddedSkins="false"
Height="390px" Width="99.5%">
<MasterTableView InsertItemDisplay="Bottom" Width="100%" DataKeyNames="Security"
Visible="true">
<RowIndicatorColumn>
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px" />
</ExpandCollapseColumn>
<Columns>
<
telerik:GridTemplateColumn HeaderText="Order Value" ItemStyle-Width="99px" ItemStyle-HorizontalAlign="Right" UniqueName="Order Value" >
<ItemTemplate>
<asp:Label ID="OrderValue" runat="server" Text='<%# Bind("OrderValue") %>' />
</ItemTemplate>
</telerik:GridTemplateColumn>
am using above structure grid ,plz help me in setting number format comma seperation in asp:label

Try the following approach to set format for text in Label control.
ASPX:
<
telerik:GridTemplateColumn
HeaderText
=
"Order Value"
ItemStyle-Width
=
"99px"
ItemStyle-HorizontalAlign
=
"Right"
UniqueName
=
"Order Value"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"OrderValue"
runat
=
"server"
Text=' <%# string.Format("{0:n}", Convert.ToInt64(Eval("OrderValue"))) %> ' />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
You can also try it from code behind like below.
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
Label lb = (Label)item.FindControl(
"OrderValue"
);
Int64 value = Convert.ToInt64(lb.Text);
lb.Text= String.Format(
"{0:n}"
, value);
}
}
Thanks,
Princy.

i tried to use it bth are working fine
but the value is comming as ex:- 699,461,112,789.432
if i want to bring the comma seperation in indian format 69,94,61,12,789.432 separated by 2 digits how to achieve it
i tried the below code yet its not resolved,
<telerik:GridTemplateColumn HeaderText="Deficiency" ItemStyle-Width="99px" ItemStyle-HorizontalAlign="Right" UniqueName="DEFICIENCY">
<ItemTemplate>
<asp:Label ID="DEFICIENCY" runat="server" Text='<%# string.Format("{0:##,##,###,##,##,##,###.##}", Convert.ToDouble(Eval("DEFICIENCY"))) %>'>
</asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
please help me out in this respect
Thanks regards,
Siva.