Hello,
I'm using Q1 2010
I have implemented a RadGrid as follows:
with this code behind:
My problem is with the calculation(see code behind in Grid1_ItemDataBound), which are displayed in "txtTotalTime" textbox, without paging the calculations work fine. However with paging, each page of the grid behaves like an independent grid and on each page i get the calculations of items of the current page only and not for the entire grid. I need to see on each page of the grid the calculation of all items of the grid.
I would appreciate any help.
Best Regards
Yuri
I'm using Q1 2010
I have implemented a RadGrid as follows:
<telerik:RadAjaxPanel ID="RadAjaxPanel" runat="server"> |
<telerik:RadGrid ID="Grid1" runat="server" ShowStatusBar="True" AllowPaging="true" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Skin="Black" OnItemDataBound="Grid1_ItemDataBound"> |
<MasterTableView Width="100%" ShowHeader="true" CommandItemDisplay="None" ShowFooter="true" DataKeyNames="itm_TableID" ClientDataKeyNames="itm_TableID" DataSourceID="SqlDataSource1" PageSize="10" |
AutoGenerateColumns="False" Dir="RTL" AllowSorting="true" TableLayout="Fixed" PagerStyle-AlwaysVisible="true"> |
<Columns> |
<telerik:GridBoundColumn UniqueName="itm_TableID" DataField="itm_TableID" HeaderText="ID" ReadOnly="true" HeaderStyle-Width="2%" Display="false"> |
</telerik:GridBoundColumn> |
<telerik:GridTemplateColumn UniqueName="CategorySelect" ItemStyle-Width="3%"> |
<ItemTemplate> |
<asp:CheckBox id="chkCategorySelect" OnCheckedChanged="chkCategorySelect_Click" AutoPostBack="True" runat="server" CssClass="checkBox"></asp:CheckBox> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridBoundColumn UniqueName="itm_ID" DataField="itm_ID" HeaderText="" ReadOnly="true" HeaderStyle-Width="3%" ItemStyle-Width="3%" HeaderStyle-HorizontalAlign="Right"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn UniqueName="itm_VTR" DataField="itm_VTR" HeaderText="VTR" HeaderStyle-Width="3%" ItemStyle-Width="3%" HeaderStyle-HorizontalAlign="Right"> |
<HeaderStyle Width="3%"></HeaderStyle> |
</telerik:GridBoundColumn> |
<telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="" HeaderStyle-Width="15%" ItemStyle-Width="15%" FooterStyle-Width="15%" FooterStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Right"> |
<FooterTemplate> |
<telerik:RadTextBox ID="txtTotalTime" Runat="server" Skin="Black" Label="" Width="120px" ReadOnly="true"> |
</telerik:RadTextBox> |
</FooterTemplate> |
<ItemTemplate> |
<asp:Label ID="lblRemarks" runat="server" Text='<%# Bind("itm_Remarks", "{0}") %>'></asp:Label> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
</Columns> |
<PagerTemplate> |
<div style="direction: rtl;"> |
<asp:Panel ID="PagerPanel" Style="padding: 6px; line-height: 24px;" runat="server" Direction="RightToLeft"> |
<asp:Button ID="btnAdd" runat="server" Width="100px" Text="" CssClass="" Enabled="true" OnClick="btnAddToCategory_Click" /> |
<asp:Panel runat="server" ID="NumericPagerPlaceHolder" Direction="RightToLeft"/> |
</asp:Panel> |
</div> |
</PagerTemplate> |
<PagerStyle Mode="NumericPages" Position="TopAndBottom" HorizontalAlign="Center" /> |
</MasterTableView> |
<ClientSettings AllowRowsDragDrop="false" EnableRowHoverStyle="false" EnablePostBackOnRowClick="false"> |
<Selecting AllowRowSelect="false" EnableDragToSelectRows="false" /> |
<Resizing AllowColumnResize="false" ClipCellContentOnResize="true" /> |
</ClientSettings> |
<HeaderContextMenu EnableAutoScroll="True"></HeaderContextMenu> |
</telerik:RadGrid> |
</telerik:RadAjaxPanel> |
protected void Page_Load(object sender, EventArgs e) |
{ |
} |
DateTime totalTime = new DateTime(); |
protected void Grid1_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridDataItem) |
{ |
GridDataItem dataItem = (GridDataItem)e.Item; |
totalTime = totalTime.AddSeconds(Double.Parse(dataItem["itm_VTR"].Text)); |
} |
else if (e.Item is GridFooterItem && endTime < castLength) |
{ |
GridFooterItem footer = (GridFooterItem)e.Item; |
(footer["TemplateColumn"].FindControl("txtTotalTime") as RadTextBox).Text = totalTime.ToString("HH:mm:ss"); |
} |
} |
My problem is with the calculation(see code behind in Grid1_ItemDataBound), which are displayed in "txtTotalTime" textbox, without paging the calculations work fine. However with paging, each page of the grid behaves like an independent grid and on each page i get the calculations of items of the current page only and not for the entire grid. I need to see on each page of the grid the calculation of all items of the grid.
I would appreciate any help.
Best Regards
Yuri