Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
175 views
When I export to excel only one column (UnitSF) is being exported.  Any suggestions? 
I also found it works for  <Excel Format = "Html" />
But NOT for  <Excel Format = "ExcelML" />
Note: exporting to pdf exports all columns.
<telerik:RadGrid runat="server" ID="RadGrid1" AllowPaging="True" AllowSorting="True"
                    AllowFilteringByColumn="True" PageSize="50" AutoGenerateColumns="False" DataSourceID="ds1"
                    GridLines="None" Height="500px" ShowFooter="True" Skin="WebBlue"
                     OnExcelMLExportRowCreated="RadGrid1_ExcelMLExportRowCreated"
                     OnExcelMLExportStylesCreated="RadGrid1_ExcelMLExportStylesCreated"
                     ShowStatusBar="true">
                    <ClientSettings>
                        <ClientEvents OnRowContextMenu="RowContextMenu" />
                        <Resizing AllowColumnResize="true" AllowResizeToFit="true" ClipCellContentOnResize="false" />
                        <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" />
                    </ClientSettings>
                    <ExportSettings ExportOnlyData="true" IgnorePaging="false"  OpenInNewWindow="true">
                        <Excel Format="ExcelML" />
                    </ExportSettings>
                    <SortingSettings SortedBackColor="Red" />
                    <MasterTableView TableLayout="Fixed" OnDataBinding="MasterTableView_DataBinding"
                        OverrideDataSourceControlSorting="true" EnableHeaderContextMenu="true" EnableHeaderContextAggregatesMenu="true"
                        EnableHeaderContextFilterMenu="true" CommandItemDisplay="Bottom">
                        <PagerStyle Mode="NextPrevNumericAndAdvanced" AlwaysVisible="True" />
                        <CommandItemSettings ShowAddNewRecordButton="false" ShowExportToPdfButton="true"
                            ExportToPdfText="Export to PDF" ShowExportToExcelButton="true" />
                        <Columns>
                            <telerik:GridCheckBoxColumn DataField="FutureLease" DataType="System.Boolean" FilterControlAltText="Filter FutureLease column"
                                HeaderText="Future Lease" SortExpression="FutureLease" UniqueName="FutureLease"
                                HeaderStyle-Width="120px">
                            </telerik:GridCheckBoxColumn>
                            <telerik:GridBoundColumn DataField="ShoppingCenterID" FilterControlAltText="Filter ShoppingCenterID column"
                                HeaderText="Shopping Center ID" SortExpression="ShoppingCenterID" UniqueName="ShoppingCenterID"
                                HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="ShoppingCenterName" FilterControlAltText="Filter ShoppingCenterName column"
                                HeaderText="Shopping Center Name" SortExpression="ShoppingCenterName" UniqueName="ShoppingCenterName"
                                HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="UnitNumber" FilterControlAltText="Filter UnitNumber column"
                                HeaderText="Unit #" SortExpression="UnitNumber" UniqueName="UnitNumber" HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="LeaseNumber" DataType="System.Int32" FilterControlAltText="Filter LeaseNumber column"
                                HeaderText="Lease Number" SortExpression="LeaseNumber" UniqueName="LeaseNumber"
                                HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="UnitSF" DataType="System.Int32" FilterControlAltText="Filter UnitSF column"
                                HeaderText="UnitSF" SortExpression="UnitSF" UniqueName="UnitSF" DataFormatString="{0:n0}"
                                Aggregate="Sum" HeaderStyle-Width="120px">
                                <ItemStyle HorizontalAlign="Right" />
                                <FooterStyle HorizontalAlign="Right" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="TenantName" FilterControlAltText="Filter TenantName column"
                                HeaderText="TenantName" SortExpression="TenantName" UniqueName="TenantName" HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="TenantNumber" DataType="System.Int32" FilterControlAltText="Filter TenantNumber column"
                                HeaderText="TenantNumber" SortExpression="TenantNumber" UniqueName="TenantNumber"
                                HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="LeaseBeginDate" DataType="System.DateTime" FilterControlAltText="Filter LeaseBeginDate column"
                                HeaderText="Lease Begin Date" SortExpression="LeaseBeginDate" UniqueName="LeaseBeginDate"
                                DataFormatString="{0:MM/dd/yyyy}" HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="MoveInDate" DataType="System.DateTime" FilterControlAltText="Filter MoveInDate column"
                                HeaderText="Move In Date" SortExpression="MoveInDate" UniqueName="MoveInDate"
                                DataFormatString="{0:MM/dd/yyyy}" HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="LeaseEndDate" DataType="System.DateTime" FilterControlAltText="Filter LeaseEndDate column"
                                HeaderText="LeaseEndDate" SortExpression="LeaseEndDate" UniqueName="LeaseEndDate"
                                DataFormatString="{0:MM/dd/yyyy}" HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="LeaseStatus" FilterControlAltText="Filter LeaseStatus column"
                                HeaderText="LeaseStatus" SortExpression="LeaseStatus" UniqueName="LeaseStatus"
                                HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="UnitType" FilterControlAltText="Filter UnitType column"
                                HeaderText="UnitType" SortExpression="UnitType" UniqueName="UnitType" HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="LastTenantMoveoutDate" DataType="System.DateTime"
                                FilterControlAltText="Filter LastTenantMoveoutDate column" HeaderText="LastTenantMoveoutDate"
                                SortExpression="LastTenantMoveoutDate" UniqueName="LastTenantMoveoutDate" DataFormatString="{0:MM/dd/yyyy}"
                                HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="LastTenantBaseRent" DataType="System.Decimal"
                                FilterControlAltText="Filter LastTenantBaseRent column" HeaderText="LastTenantBaseRent"
                                SortExpression="LastTenantBaseRent" UniqueName="LastTenantBaseRent" HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="LeaseType" FilterControlAltText="Filter LeaseType column"
                                HeaderText="LeaseType" SortExpression="LeaseType" UniqueName="LeaseType" HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="ActualMoveoutDate" DataType="System.DateTime"
                                FilterControlAltText="Filter ActualMoveoutDate column" HeaderText="ActualMoveoutDate"
                                SortExpression="ActualMoveoutDate" UniqueName="ActualMoveoutDate" DataFormatString="{0:MM/dd/yyyy}"
                                HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="TenantSICType" FilterControlAltText="Filter TenantSICType column"
                                HeaderText="TenantSICType" SortExpression="TenantSICType" UniqueName="TenantSICType"
                                HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="LeaseULICode" FilterControlAltText="Filter LeaseULICode column"
                                HeaderText="LeaseULICode" SortExpression="LeaseULICode" UniqueName="LeaseULICode"
                                HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="BaseRentPSF" DataType="System.Decimal" FilterControlAltText="Filter BaseRentPSF column"
                                HeaderText="BaseRentPSF" SortExpression="BaseRentPSF" UniqueName="BaseRentPSF"
                                DataFormatString="{0:c2}" HeaderStyle-Width="120px">
                                <ItemStyle HorizontalAlign="Right" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="CAMPSF" DataType="System.Decimal" FilterControlAltText="Filter CAMPSF column"
                                HeaderText="CAMPSF" SortExpression="CAMPSF" UniqueName="CAMPSF" DataFormatString="{0:c2}"
                                HeaderStyle-Width="120px">
                                <ItemStyle HorizontalAlign="Right" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="TAXPSF" DataType="System.Decimal" FilterControlAltText="Filter TAXPSF column"
                                HeaderText="TAXPSF" SortExpression="TAXPSF" UniqueName="TAXPSF" DataFormatString="{0:c2}"
                                HeaderStyle-Width="120px">
                                <ItemStyle HorizontalAlign="Right" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="INSPSF" DataType="System.Decimal" FilterControlAltText="Filter INSPSF column"
                                HeaderText="INSPSF" SortExpression="INSPSF" UniqueName="INSPSF" DataFormatString="{0:c2}"
                                HeaderStyle-Width="120px">
                                <ItemStyle HorizontalAlign="Right" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="OtherPSF" DataType="System.Decimal" FilterControlAltText="Filter OtherPSF column"
                                HeaderText="OtherPSF" SortExpression="OtherPSF" UniqueName="OtherPSF" DataFormatString="{0:c2}"
                                HeaderStyle-Width="120px">
                                <ItemStyle HorizontalAlign="Right" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="GrossChargesPSF" DataType="System.Decimal" FilterControlAltText="Filter GrossChargesPSF column"
                                HeaderText="GrossChargesPSF" SortExpression="GrossChargesPSF" UniqueName="GrossChargesPSF"
                                DataFormatString="{0:c2}" HeaderStyle-Width="120px">
                                <ItemStyle HorizontalAlign="Right" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="BaseRentAnnual" DataType="System.Decimal" FilterControlAltText="Filter BaseRentAnnual column"
                                HeaderText="BaseRentAnnual" SortExpression="BaseRentAnnual" UniqueName="BaseRentAnnual"
                                DataFormatString="{0:c2}" HeaderStyle-Width="120px">
                                <ItemStyle HorizontalAlign="Right" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="CAMAnnual" DataType="System.Decimal" FilterControlAltText="Filter CAMAnnual column"
                                HeaderText="CAMAnnual" SortExpression="CAMAnnual" UniqueName="CAMAnnual" DataFormatString="{0:c2}"
                                HeaderStyle-Width="120px">
                                <ItemStyle HorizontalAlign="Right" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="TAXAnnual" DataType="System.Decimal" FilterControlAltText="Filter TAXAnnual column"
                                HeaderText="TAXAnnual" SortExpression="TAXAnnual" UniqueName="TAXAnnual" DataFormatString="{0:c2}"
                                HeaderStyle-Width="120px">
                                <ItemStyle HorizontalAlign="Right" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="INSAnnual" DataType="System.Decimal" FilterControlAltText="Filter INSAnnual column"
                                HeaderText="INSAnnual" SortExpression="INSAnnual" UniqueName="INSAnnual" DataFormatString="{0:c2}"
                                HeaderStyle-Width="120px">
                                <ItemStyle HorizontalAlign="Right" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="OtherAnnual" DataType="System.Decimal" FilterControlAltText="Filter OtherAnnual column"
                                HeaderText="OtherAnnual" SortExpression="OtherAnnual" UniqueName="OtherAnnual"
                                DataFormatString="{0:c2}" HeaderStyle-Width="120px">
                                <ItemStyle HorizontalAlign="Right" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="GrossAnnual" DataType="System.Decimal" FilterControlAltText="Filter GrossAnnual column"
                                HeaderText="GrossAnnual" SortExpression="GrossAnnual" UniqueName="GrossAnnual"
                                DataFormatString="{0:c2}" HeaderStyle-Width="120px">
                                <ItemStyle HorizontalAlign="Right" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="LeaseVersion" DataType="System.Int32" FilterControlAltText="Filter LeaseVersion column"
                                HeaderText="LeaseVersion" SortExpression="LeaseVersion" UniqueName="LeaseVersion"
                                HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Division" FilterControlAltText="Filter Division column"
                                HeaderText="Division" SortExpression="Division" UniqueName="Division" HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="SuperRegion" FilterControlAltText="Filter SuperRegion column"
                                HeaderText="SuperRegion" SortExpression="SuperRegion" UniqueName="SuperRegion"
                                HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Region" FilterControlAltText="Filter Region column"
                                HeaderText="Region" SortExpression="Region" UniqueName="Region" HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridCheckBoxColumn DataField="IsHotTenant" DataType="System.Boolean" FilterControlAltText="Filter IsHotTenant column"
                                HeaderText="IsHotTenant" SortExpression="IsHotTenant" UniqueName="IsHotTenant"
                                HeaderStyle-Width="120px">
                            </telerik:GridCheckBoxColumn>
                            <telerik:GridBoundColumn DataField="LeaseActivityCode8" FilterControlAltText="Filter LeaseActivityCode8 column"
                                HeaderText="LeaseActivityCode8" SortExpression="LeaseActivityCode8" UniqueName="LeaseActivityCode8"
                                HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridCheckBoxColumn DataField="LeaseHasOptions" DataType="System.Boolean"
                                FilterControlAltText="Filter LeaseHasOptions column" HeaderText="LeaseHasOptions"
                                SortExpression="LeaseHasOptions" UniqueName="LeaseHasOptions" HeaderStyle-Width="120px">
                            </telerik:GridCheckBoxColumn>
                            <telerik:GridCheckBoxColumn DataField="LeaseHasRentSteps" DataType="System.Boolean"
                                FilterControlAltText="Filter LeaseHasRentSteps column" HeaderText="LeaseHasRentSteps"
                                SortExpression="LeaseHasRentSteps" UniqueName="LeaseHasRentSteps" HeaderStyle-Width="120px">
                            </telerik:GridCheckBoxColumn>
                            <telerik:GridBoundColumn DataField="LeaseSupplementalDate" DataType="System.DateTime"
                                FilterControlAltText="Filter LeaseSupplementalDate column" HeaderText="LeaseSupplementalDate"
                                SortExpression="LeaseSupplementalDate" UniqueName="LeaseSupplementalDate" DataFormatString="{0:MM/dd/yyyy}"
                                HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="LeaseULIDescription" FilterControlAltText="Filter LeaseULIDescription column"
                                HeaderText="LeaseULIDescription" SortExpression="LeaseULIDescription" UniqueName="LeaseULIDescription"
                                HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="LeasedSF" DataType="System.Int32" FilterControlAltText="Filter LeasedSF column"
                                HeaderText="LeasedSF" SortExpression="LeasedSF" UniqueName="LeasedSF" HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="LeasingAgent" FilterControlAltText="Filter LeasingAgent column"
                                HeaderText="LeasingAgent" SortExpression="LeasingAgent" UniqueName="LeasingAgent"
                                HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="ParentTenantName" FilterControlAltText="Filter ParentTenantName column"
                                HeaderText="ParentTenantName" SortExpression="ParentTenantName" UniqueName="ParentTenantName"
                                HeaderStyle-Width="120px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="PropertyManager" FilterControlAltText="Filter PropertyManager column"
                                HeaderText="PropertyManager" SortExpression="PropertyManager" UniqueName="PropertyManager"
                                HeaderStyle-Width="120px">
                                <FilterTemplate>
                                    <telerik:RadComboBox ID="RadComboBoxPropertyManager" DataSourceID="dsPM" DataTextField="Text"
                                        DataValueField="Value" Height="200px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("PropertyManager").CurrentFilterValue %>'
                                        runat="server" OnClientSelectedIndexChanged="PMChanged">
                                        <Items>
                                            <telerik:RadComboBoxItem Text="All" />
                                        </Items>
                                    </telerik:RadComboBox>
                                    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                                        <script type="text/javascript">
                                            function PMChanged(sender, args) {
                                                var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                                tableView.filter("PropertyManager", args.get_item().get_value(), "EqualTo");
 
                                            }
                                        </script>
                                    </telerik:RadScriptBlock>
                                </FilterTemplate>
                            </telerik:GridBoundColumn>
                        </Columns>
                    </MasterTableView>
                    <PagerStyle AlwaysVisible="True" />
                    <FilterMenu EnableImageSprites="False">
                    </FilterMenu>
                    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
                    </HeaderContextMenu>
                </telerik:RadGrid>
JonathanElsner
Top achievements
Rank 1
 answered on 28 Jul 2011
10 answers
238 views

Hi, I get the error below when using RadScriptManager with Obout Show from www.obout.com. Is there a way to fix this ?

Object reference not set to an instance of an object

ssomeone
Top achievements
Rank 1
 answered on 28 Jul 2011
3 answers
135 views
This is how I get cell value from edited row on client side (function attached onBlur):

function estCost(sender, args) {
                var grid = $find('<%= rg_OpenWIP.ClientID %>');
                var idx = grid._editIndexes[0];
                var masterTable = grid.get_masterTableView();
                var items = masterTable.get_dataItems();
                var estCost = parseFloat(items[idx]._element.cells[5].getElementsByTagName('input')[1].value);
                                      ...
}

Now I need same for inserted row while editing. How?
Yurii
Top achievements
Rank 1
 answered on 28 Jul 2011
6 answers
127 views
I've had a RadTreeview working inside a Radcombobox, and I pre select the tree nodes based on the last value selected using. This has stopped woring since I upgraded to the latest version of the controls.

Has anyone else noticed this?

Andy
Thad
Top achievements
Rank 2
 answered on 28 Jul 2011
4 answers
182 views
Hello all

I am using a radgrid with a pager :

<telerik:RadGrid ID="ResultsGrid" runat="server" AllowPaging="True" AllowSorting="True" OnSortCommand="RadGrid_SortCommand" EnableViewState="true"
                         AutoGenerateColumns="False" GridLines="None"  ShowHeader="true"
                         PageSize="7" OnItemCommand="HandleDoubleclick" Width="99%">
        <MasterTableView DataKeyNames="Id,Abstract,InternalId" CanRetrieveAllData="false">
            <Columns>
[...]

Then in the UI, when the user clicks on a page number, there is a postback (as it seems) that makes the user wait for the reloading (which is fine); but when he clicks on the button "Next page" or "Previous page", there is not this postback ... so we have the feeling that nothing happened for 1 or 2 sec. and then the page changes.
How can I have the same behavior as for when we click on the page numbers ?
Thanks for your help,
Sylvain
Sylvain
Top achievements
Rank 1
 answered on 28 Jul 2011
7 answers
83 views
Checking in on this request....is it in Q2 by any chance?

Property of something like "InsertEmptyItemOnDataBind"...so I wouldn't have to keep handling OnDataBound to add a empty\null item to the top of the list in every combobox?

Simon
Telerik team
 answered on 28 Jul 2011
1 answer
57 views
Hello,
I am trying to show $0 in radalert.But it's showing as {1}.

radalert('$0');

outPut:  {1}
instead of  $0

Is there any work around?
Can somebody help me on this......
Svetlina Anati
Telerik team
 answered on 28 Jul 2011
3 answers
243 views
Hi,

I am using Telerik grid hierarchy of 3 levels i.e., Master Table, Details Table and Details Table. I have applied pager style

<

 

 

PagerStyle Mode="NextPrevNumericAndAdvanced" AlwaysVisible="true" />

 

paging for Master level with pagesize=10, and i have set paging = false for the details tables in GridTableView. It is showing like "Item 0 to 0 of 0" and only page 1 is displayed, in the paging, even If I have more than 100 rows. And sorting is also not working. Is it because of the hierarchy grid of 3 levels, these are not working?. Because these both functionalites are working at other places where I have not used any Details Table.

Below pasted is the sample code which I am using. I have removed all the columns in it.
<telerik:RadGrid ID="RadGridProject" DataSourceID="sds_p" runat="server" AllowAutomaticUpdates="True"
      AutoGenerateColumns="False" OnDataBound="RadGridProject_DataBound" PageSize="10"
      AllowSorting="true" OnItemCommand="RadGridProject_ItemCommand" AutoGenerateHierarchy="true"
      OnItemDataBound="RadGridProject_ItemDataBound" AllowCustomPaging="True">
      <PagerStyle Mode="NextPrevNumericAndAdvanced" AlwaysVisible="true" />
      <MasterTableView Name="PTable" DataKeyNames="P_id,p_y_id" AllowMultiColumnSorting="True"
          AllowSorting="true" TableLayout="Fixed" EditMode="InPlace" AllowCustomPaging="true"
          AllowPaging="true">
          <HeaderStyle CssClass="Level1HeaderStyle" />
                   <Columns>
                   </Columns>
          <DetailTables>
              <telerik:GridTableView DataKeyNames="faf_id, faf_year_id" DataSourceID="sds_f"
                  AllowPaging="false" Width="60%" HeaderStyle-Width="10px" Name="FTable"
                  TableLayout="Auto" AllowFilteringByColumn="false">
                  <ParentTableRelation>
                      <telerik:GridRelationFields DetailKeyField="p_id" MasterKeyField="P_id" />
                  </ParentTableRelation>
                  <DetailTables>
                      <telerik:GridTableView DataSourceID="sds_d" DataKeyNames="f_id, d_id"
                          Width="80%" AllowFilteringByColumn="false" Name="DTable" runat="server"
                          AllowPaging="false" EditMode="InPlace" TableLayout="Auto">
                          <ParentTableRelation>
                              <telerik:GridRelationFields DetailKeyField="year_id" MasterKeyField="year_id" />
                          </ParentTableRelation>
                          <HeaderStyle CssClass="Level3HeaderStyle" />
                          <ItemStyle CssClass="Level3ItemStyle" Width="10px" />
                          <AlternatingItemStyle CssClass="Level3AltItemStyle" />
                          <Columns>
                             </Columns>
                          <SortExpressions>
                              <telerik:GridSortExpression FieldName="name"  sortOrder="Ascending"> </telerik:GridSortExpression>
                          </SortExpressions>
                      </telerik:GridTableView>
                  </DetailTables>
                  <ItemStyle Width="200px" />
                  <HeaderStyle CssClass="Level2HeaderStyle" Width="100%" />
                  <ItemStyle CssClass="Level2ItemStyle" />
                  <AlternatingItemStyle CssClass="Level2AltItemStyle" />
                  <Columns>
                   </Columns>
                  <SortExpressions>
                      <telerik:GridSortExpression FieldName="f_id"></telerik:GridSortExpression>
                  </SortExpressions>
              </telerik:GridTableView>
          </DetailTables>
          <SortExpressions>
              <telerik:GridSortExpression FieldName="t_name"></telerik:GridSortExpression>
          </SortExpressions>
      </MasterTableView>
      <ClientSettings AllowColumnsReorder="true" ReorderColumnsOnClient="true">
      </ClientSettings>
  </telerik:RadGrid>

Thanks
Gopi Krishna

JJ
Top achievements
Rank 1
 answered on 28 Jul 2011
1 answer
127 views
All,

I have a grid in a usercontrol. That grid has a column with tooltips. The tooltip content is another usercontrol that contains another grid.
I have followed numerous examples of how to accomplish this using the ToolTipManager and the RadAjaxManager.

I cannot seem to get the detail grid to display correct data after button actions. I can see the NeedDataSource event being called and I know the data is there, it is just not being refreshed.

Any and all help is greatly appreciated.

Thanks,
B

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ApplyPaymentList.ascx.cs"
    Inherits="LaundryLogic.Modules.LL_ARActivities.ApplyPaymentList" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<telerik:RadScriptBlock runat="server">
 
    <script type="text/javascript">
 
    function RebindCredits()
    {
        var masterTable = $find("<%= rgCredits.ClientID %>").get_masterTableView();
        masterTable.rebind();
 
    }
    </script>
</telerik:RadScriptBlock>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
   <AjaxSettings>
       <telerik:AjaxSetting AjaxControlID="rgCredits">
           <UpdatedControls>
               <telerik:AjaxUpdatedControl ControlID="RadToolTipManager1" />
               <telerik:AjaxUpdatedControl ControlID="rgCredits" />
           </UpdatedControls>
       </telerik:AjaxSetting>
   </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadToolTipManager ID="RadToolTipManager1" OffsetY="-1" HideEvent="ManualClose"
   Width="800" Height="800" runat="server" EnableShadow="true" OnAjaxUpdate="OnAjaxUpdate"
   RelativeTo="BrowserWindow" Position="Center" ShowCallout="false" ShowEvent="OnClick" OnClientHide="RebindCredits">
</telerik:RadToolTipManager>
 
<table width="100%">
    <tr>
        <td>
            <asp:Label ID="lblHeader1" runat="server" CssClass="moduleheader" Text="Apply Customer Payments to Invoices"></asp:Label>
            -
            <asp:Label ID="lblHeader2" runat="server" CssClass="moduleheader" Text="You are working on Payment Batch Number "></asp:Label>
        </td>
    </tr>
    <tr>
        <td>
            <hr />
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="lblHeader3" runat="server" CssClass="moduleheader" Text="Customer Payments in this Batch"></asp:Label>
        </td>
    </tr>
    <tr>
        <td>
            <telerik:RadGrid ID="rgCredits" runat="server" AllowPaging="True" AllowSorting="True"
                AutoGenerateColumns="False" GridLines="None" EnableEmbeddedSkins="False"
                onneeddatasource="rgCredits_NeedDataSource" Skin="Sitefinity"
                onitemcommand="rgCredits_ItemCommand" onitemdatabound="rgCredits_ItemDataBound">
                <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
                </HeaderContextMenu>
                <MasterTableView DataKeyNames="ID,EntityType,EntityID">
                    <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
                    <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </ExpandCollapseColumn>
                    <Columns>
                                    <telerik:GridDateTimeColumn DataField="CreditDate" DataFormatString="{0:MM/dd/yyyy}"
                                        DataType="System.DateTime" FilterControlAltText="Filter CreditDate column" HeaderText="Credit Date"
                                        UniqueName="CreditDate">
                                    </telerik:GridDateTimeColumn>
                                    <telerik:GridBoundColumn DataField="AccountName" FilterControlAltText="Filter AccountName column"
                                        HeaderText="Account Name" MaxLength="20" UniqueName="AccountName">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="AccountNumber" FilterControlAltText="Filter AccountNumber column"
                                        HeaderText="Account Number" MaxLength="20" UniqueName="AccountNumber">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridTemplateColumn DataField="ActivityTypeID" FilterControlAltText="Filter ActivityType column"
                                        HeaderText="Type" UniqueName="ActivityType">
                                        <EditItemTemplate>
                                            <telerik:RadComboBox ID="rcbActivityType" runat="server">
                                            </telerik:RadComboBox>
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="lblActivityType" runat="server" Text='<%# Eval("ActivityTypeID") %>'></asp:Label>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridBoundColumn DataField="CreditIdentifier" FilterControlAltText="Filter CreditIdentifier column"
                                        HeaderText="Credit Identifier" MaxLength="20" UniqueName="CreditIdentifier">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridTemplateColumn DataField="OriginalAmount" HeaderText="Original Amt."
                                        UniqueName="OriginalAmount">
                                        <EditItemTemplate>
                                            <telerik:RadNumericTextBox ID="rntOriginalAmount" runat="server" CausesValidation="True"
                                                DataType="System.Decimal" Type="Currency">
                                            </telerik:RadNumericTextBox>
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="lblOriginalAmount" runat="server" Text='<%# Eval("OriginalAmount", "{0:c}") %>'></asp:Label>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridNumericColumn DataField="RemainingAmount" DataType="System.Decimal"
                                        DecimalDigits="2" FilterControlAltText="Filter RemainingAmount column" HeaderText="Remaining Amt."
                                        NumericType="Currency" ReadOnly="True" UniqueName="RemainingAmount">
                                    </telerik:GridNumericColumn>
                                    <telerik:GridBoundColumn DataField="PaymentBatchID" Display="false" FilterControlAltText="Filter Payment Batch ID column"
                                        HeaderText="Payment Batch ID" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn ColumnEditorID="GridTextBoxColumnEditor1" DataField="Notes"
                                        FilterControlAltText="Filter Notes column" HeaderText="Notes" MaxLength="500"
                                        UniqueName="Notes">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="CreatedBy" Display="False" FilterControlAltText="Filter CreatedBy column"
                                        HeaderText="Created By" MaxLength="50" ReadOnly="True" UniqueName="CreatedBy">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridButtonColumn CommandName="Apply" FilterControlAltText="Filter Apply column"
                                        Text="Apply This Payment" UniqueName="Apply">
                                    </telerik:GridButtonColumn>
                                </Columns>
                    <EditFormSettings>
                        <EditColumn FilterControlAltText="Filter EditCommandColumn column"
                            cancelimageurl="Cancel.gif" editimageurl="Edit.gif" insertimageurl="Update.gif"
                            updateimageurl="Update.gif">
                        </EditColumn>
                    </EditFormSettings>
                </MasterTableView>
                <FilterMenu EnableImageSprites="False">
                </FilterMenu>
            </telerik:RadGrid>
        </td>
    </tr>
    <tr>
        <td>
            <hr />
        </td>
    </tr>
    <tr>
        <td>
            <telerik:RadButton ID="rbtnPaymentBatchManagement" runat="server"
                Text="Batch Manager" CausesValidation="false"
                onclick="rbtnPaymentBatchManagement_Click">
                <Icon PrimaryIconCssClass="rbPrevious" />
            </telerik:RadButton>
        </td>
    </tr>
</table>

using DotNetNuke.Common;
 
using EntitySpaces.Interfaces;
 
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
using Telerik.Web.UI;
 
namespace LaundryLogic.Modules.LL_ARActivities
{
    public partial class ApplyPaymentList : LL_ARActivitiesModuleBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["PaymentBatchID"] != null)
            {
                lblHeader2.Text = lblHeader2.Text + Request["PaymentBatchID"].ToString();
            }
        }
 
        protected void rgCredits_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            DataTable oDTMaster = new DataTable();
            DataTable oDTStandard = new DataTable();
            DataTable oDT = new DataTable();
 
            oDTMaster = LoadMasterPayments();
            oDTStandard = LoadStandardPayments();
            oDT.Merge(oDTMaster);
            oDT.Merge(oDTStandard);
 
            if (oDT != null)
            {
                rgCredits.DataSource = oDT;
            }
            else
            {
                rgCredits.DataSource = new object[0];
            }
 
        }
 
        private DataTable LoadMasterPayments()
        {
            LaundryLogicDAL.ARCreditsQuery oARCQ = new LaundryLogicDAL.ARCreditsQuery("arc");
            LaundryLogicDAL.ARActivityTypeQuery oARATQ = new LaundryLogicDAL.ARActivityTypeQuery("arat");
            LaundryLogicDAL.ARAccountsQuery oARAQ = new LaundryLogicDAL.ARAccountsQuery("araq");
            LaundryLogicDAL.ARMasterQuery oARMQ = new LaundryLogicDAL.ARMasterQuery("armq");
 
            DataTable oDT = new DataTable();
            DataTable oDTStandard = new DataTable();
 
            try
            {
 
                oARCQ.es2.Connection.Name = "NAS";
                oARCQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oARATQ.es2.Connection.Name = "NAS";
                oARATQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oARAQ.es2.Connection.Name = "NAS";
                oARAQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oARMQ.es2.Connection.Name = "NAS";
                oARMQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
 
                oARCQ.Select(
                    oARCQ.Id,
                    oARCQ.EntityType,
                    oARCQ.EntityID,
                    oARMQ.AccountName,
                    "<'N/A' AS [AccountNumber]>",
                    oARCQ.CreditDate,
                    oARCQ.ActivityTypeID,
                    oARATQ.ActivityType,
                    oARCQ.CreditIdentifier,
                    oARCQ.OriginalAmount,
                    oARCQ.RemainingAmount,
                    oARCQ.Notes,
                    oARCQ.PaymentBatchID,
                    oARCQ.CreatedBy,
                    oARCQ.CreateDate
                );
                oARCQ.InnerJoin(oARATQ).On(oARCQ.ActivityTypeID == oARATQ.Id);
                oARCQ.InnerJoin(oARMQ).On(oARCQ.EntityID == oARMQ.Id);
                oARCQ.Where(oARCQ.EntityType == "Master");
 
                if (Request["PaymentBatchID"] != null)
                {
                    oARCQ.Where(oARCQ.PaymentBatchID == Convert.ToInt16(Request["PaymentBatchID"]));
                }
 
                return oARCQ.LoadDataTable();
 
 
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
                return null;
            }
            finally
            {
                //oARCC.Dispose();
                //oARCC = null;
                oARCQ = null;
                oARATQ = null;
                oARAQ = null;
                oARMQ = null;
                oDT = null;
 
            }
        }
 
        private DataTable LoadStandardPayments()
        {
            LaundryLogicDAL.ARCreditsQuery oARCQ = new LaundryLogicDAL.ARCreditsQuery("arc");
            LaundryLogicDAL.ARActivityTypeQuery oARATQ = new LaundryLogicDAL.ARActivityTypeQuery("arat");
            LaundryLogicDAL.ARAccountsQuery oARAQ = new LaundryLogicDAL.ARAccountsQuery("araq");
            LaundryLogicDAL.ARMasterQuery oARMQ = new LaundryLogicDAL.ARMasterQuery("armq");
 
            DataTable oDT = new DataTable();
            DataTable oDTStandard = new DataTable();
 
            try
            {
 
                oARCQ.es2.Connection.Name = "NAS";
                oARCQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oARATQ.es2.Connection.Name = "NAS";
                oARATQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oARAQ.es2.Connection.Name = "NAS";
                oARAQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oARMQ.es2.Connection.Name = "NAS";
                oARMQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
 
                oARCQ.Select(
                    oARCQ.Id,
                    oARCQ.EntityType,
                    oARCQ.EntityID,
                    oARAQ.AccountName,
                    oARAQ.Account.As("AccountNumber"),
                    oARCQ.CreditDate,
                    oARCQ.ActivityTypeID,
                    oARATQ.ActivityType,
                    oARCQ.CreditIdentifier,
                    oARCQ.OriginalAmount,
                    oARCQ.RemainingAmount,
                    oARCQ.Notes,
                    oARCQ.PaymentBatchID,
                    oARCQ.CreatedBy,
                    oARCQ.CreateDate
                );
                oARCQ.InnerJoin(oARATQ).On(oARCQ.ActivityTypeID == oARATQ.Id);
                oARCQ.InnerJoin(oARAQ).On(oARCQ.EntityID == oARAQ.Id);
                oARCQ.Where(oARCQ.EntityType == "Standard");
 
                if (Request["PaymentBatchID"] != null)
                {
                    oARCQ.Where(oARCQ.PaymentBatchID == Convert.ToInt16(Request["PaymentBatchID"]));
                }
 
                return oARCQ.LoadDataTable();
 
 
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
                return null;
            }
            finally
            {
                //oARCC.Dispose();
                //oARCC = null;
                oARCQ = null;
                oARATQ = null;
                oARAQ = null;
                oARMQ = null;
                oDT = null;
 
            }
        }
 
        protected void rbtnPaymentBatchManagement_Click(object sender, EventArgs e)
        {
            Response.Redirect(Globals.NavigateURL(), true);
        }
 
        protected void OnAjaxUpdate(object sender, ToolTipUpdateEventArgs args)
        {
            this.UpdateToolTip(args.Value, args.UpdatePanel);
            rgCredits.Rebind();
        }
        private void UpdateToolTip(string elementID, UpdatePanel panel)
        {
            string[] separator = new string[] { "|" };
            string[] arrElementID = elementID.Split(separator,StringSplitOptions.None);
 
            ApplyPayments oApplyPayments = (ApplyPayments)LoadControl("ApplyPayments.ascx");
            oApplyPayments.ID = "ApplyPayments1";
            panel.ContentTemplateContainer.Controls.Add(oApplyPayments);
            oApplyPayments.EntityType = arrElementID[1].ToString();
            oApplyPayments.EntityID = Convert.ToInt16(arrElementID[2]);
            oApplyPayments.PaymentID = Convert.ToInt16(arrElementID[0]);
 
            RadGrid rgDebits = (RadGrid)oApplyPayments.FindControl("rgDebits");
 
            RadAjaxManager1.AjaxSettings.AddAjaxSetting(rgDebits, oApplyPayments);
        }
 
        protected void rgCredits_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
            {
                int iPaymentID = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"];
                string sEntityType = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["EntityType"].ToString();
                int iEntityID = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["EntityID"];
 
                GridDataItem oDataItem = (GridDataItem)e.Item;
                LinkButton lnkTarget = (LinkButton)oDataItem["Apply"].Controls[0];
                if (!Object.Equals(lnkTarget, null))
                {
                    lnkTarget.Attributes.Add("onclick", "javascript:return false;");
                    if (!Object.Equals(this.RadToolTipManager1, null))
                    {
                        //Add the button (target) id to the tooltip manager
                        string sValue = iPaymentID.ToString() + "|" + sEntityType + "|" + iEntityID.ToString();
 
                        this.RadToolTipManager1.TargetControls.Add(lnkTarget.ClientID, sValue, true);
                    }
                }
 
            }
        }
        protected void rgCredits_ItemCommand(object source, GridCommandEventArgs e)
        {
            if (e.CommandName == "Sort" || e.CommandName == "Page")
            {
                RadToolTipManager1.TargetControls.Clear();
            }
        }
    }
}
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ApplyPayments.ascx.cs"
    Inherits="LaundryLogic.Modules.LL_ARActivities.ApplyPayments" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<link href="module.css" rel="stylesheet" type="text/css" />
 
<table width="100%">
    <tr>
        <td width="20%" colspan="5">
            <asp:Label ID="lblCustomerPaymentHeader" CssClass="moduleheader" runat="server" Text="Apply Customer Payment"></asp:Label>
        </td>
    </tr>
    <tr>
        <td width="20%">
              
        </td>
        <td colspan="4">
              
        </td>
    </tr>
    <tr>
        <td colspan="5">
            <div class="divborder">
                <table>
                    <tr>
                        <td align="left">
                            <asp:Label ID="lblCustomerSelectedCaption" runat="server" Text="Customer Selected:"></asp:Label>
                        </td>
                        <td>
                            <asp:Label ID="lblAccountNumber" runat="server"></asp:Label>
                              
                        </td>
                        <td>
                            <asp:Label ID="lblAccountName" runat="server"></asp:Label>
                        </td>
                        <td align="left">
                            <asp:Label ID="lblMasterCaption" runat="server" Text="Master?"></asp:Label>
                        </td>
                        <td>
                            <asp:Label ID="lblIsMasterAccount" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td align="left">
                            <asp:Label ID="lblCreditIdentifierHeader" runat="server" Text="Payment/Check Number:"></asp:Label>
                        </td>
                        <td colspan="4">
                            <asp:Label ID="lblCreditIdentifier" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td align="left">
                            <asp:Label ID="lblCreditDateHeader" runat="server" Text="Payment/Credit Date:"></asp:Label>
                        </td>
                        <td colspan="4">
                            <asp:Label ID="lblCreditDate" runat="server"></asp:Label>
                        </td>
                    </tr>                   
                    <tr>
                        <td align="left">
                            <asp:Label ID="lblPaymentActivityTypeHeader" runat="server" Text="Payment/Credit Type:"></asp:Label>
                        </td>
                        <td colspan="4">
                            <asp:Label ID="lblPaymentActivityType" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td align="left">
                            <asp:Label ID="lblPaymentAmountHeader" runat="server" Text="Payment/Credit Amount:"></asp:Label>
                        </td>
                        <td colspan="4">
                            <asp:Label ID="lblPaymentAmount" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td align="left">
                            <asp:Label ID="lblPaymentRemainingHeader" runat="server" Text="Amount Remaining:"></asp:Label>
                        </td>
                        <td colspan="4">
                            <asp:Label ID="lblPaymentRemaining" runat="server"></asp:Label>
                        </td>
                    </tr>
                </table>
            </div>
        </td>
    </tr>
    <tr>
        <td>
              
        </td>
        <td colspan="4">
              
        </td>
    </tr>
 
    <tr>
        <td colspan="5">
            <asp:Label ID="lblOpenInvoicesHeader" CssClass="moduleheader" runat="server" Text="Open Invoices"></asp:Label>
        </td>
    </tr>
 
    <tr>
        <td>
              
        </td>
        <td colspan="4">
              
        </td>
    </tr>
    <tr>
        <td colspan="5">
            <asp:Button ID="btnAutoApply" runat="server"
    OnClick="btnAutoApply_Click" Text="AutoApply"
                 
     
                ToolTip="Automatically apply payment to as many invoices as possible beginning with the oldest invoice" />
            <asp:Button ID="btnRollbackAll" runat="server" onclick="btnRollbackAll_Click"
                Text="Rollback All" />
            <asp:Button ID="btnRollbackSelected" runat="server" onclick="btnRollbackSelected_Click"
                Text="Rollback Selected"
    CommandName="RollbackSelected" />
            <asp:Button ID="btnClearAll" runat="server"
    OnClick="btnClearAll_Click" Text="Clear All" />
        </td>
    </tr>
 
    <tr>
        <td colspan="5">
            <telerik:RadGrid Width="100%" ID="rgDebits" runat="server" AutoGenerateColumns="False"
                GridLines="None" OnNeedDataSource="rgDebits_NeedDataSource" OnItemCreated="rgDebits_ItemCreated"
                OnSortCommand="rgDebits_SortCommand" Skin="Sitefinity"
                EnableEmbeddedSkins="False"
                onprerender="rgDebits_PreRender">
                <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
                </HeaderContextMenu>
                <GroupingSettings CaseSensitive="false" />
                <ValidationSettings EnableValidation="False" />
                <MasterTableView EditMode="InPlace" DataKeyNames="ID" AllowPaging="True" ShowFooter="false">
                    <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
                    <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </ExpandCollapseColumn>
                    <Columns>
                        <telerik:GridTemplateColumn FilterControlAltText="Filter TemplateColumn column" HeaderText="Apply?"
                            UniqueName="Apply">
                            <EditItemTemplate>
                                <asp:CheckBox ID="chkApply" runat="server" AutoPostBack="True" OnCheckedChanged="chkApply_CheckedChanged" />
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="chkApply" runat="server" AutoPostBack="True" OnCheckedChanged="chkApply_CheckedChanged" />
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn FilterControlAltText="Filter AmountApplied column" HeaderText="Amount Applied"
                            UniqueName="AmountApplied">
                            <EditItemTemplate>
                                <telerik:RadNumericTextBox ID="txtAmountApplied" runat="server" Type="Currency">
                                </telerik:RadNumericTextBox>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridBoundColumn DataField="Account" DataType="System.String" FilterControlAltText="Filter Account column"
                            HeaderText="Account Number" ReadOnly="true" UniqueName="Account">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="AccountName"
                            FilterControlAltText="Filter AccountName column" HeaderText="Account Name"
                            ReadOnly="True" UniqueName="AccountName">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="DebitDate" DataType="System.DateTime" FilterControlAltText="Filter DebitDate column"
                            DataFormatString="{0:d}" HeaderText="Debit Date" ReadOnly="True" UniqueName="DebitDate">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="DebitIdentifier" FilterControlAltText="Filter DebitIdentifier column"
                            HeaderText="Debit Id" MaxLength="20" ReadOnly="True" UniqueName="DebitIdentifier">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn AllowSorting="False" DataField="OriginalAmount"
                            DataFormatString="{0:C2}" DataType="System.Decimal"
                            FilterControlAltText="Filter OriginalAmount column"
                            HeaderText="Original Amount" ReadOnly="True" UniqueName="OriginalAmount">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="RemainingAmount" DataFormatString="{0:C2}" DataType="System.Decimal"
                            FilterControlAltText="Filter RemainingAmount column" HeaderText="Remaining Amount"
                            ReadOnly="True" UniqueName="RemainingAmount" AllowSorting="False">
                        </telerik:GridBoundColumn>
                    </Columns>
                    <EditFormSettings>
                        <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                        </EditColumn>
                    </EditFormSettings>
                </MasterTableView>
                <FilterMenu EnableImageSprites="False">
                </FilterMenu>
            </telerik:RadGrid>
        </td>
    </tr>
    <tr>
        <td colspan="5">
            <telerik:RadButton runat="server" ID="rbtnApply" OnClick="cmdApply_Click" Text="Done with Applications">
                <Icon PrimaryIconCssClass="rbPrevious" />
            </telerik:RadButton>
        </td>
    </tr>
</table>
using EntitySpaces.Interfaces;
 
using System;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
using Telerik.Web.UI;
 
namespace LaundryLogic.Modules.LL_ARActivities
{
    public partial class ApplyPayments : LL_ARActivitiesModuleBase
    {
        private string msEntityType;
        private int miEntityID;
 
        private double sum = 0;
 
        public string EntityType
        {
            set
            {
                Session["EntityType"] = value;
            }
        }
 
        public int EntityID
        {
            set
            {
                Session["EntityID"] = value;
            }
        }
 
        public int PaymentID
        {
 
            set {
                int iEntityID = 0;
                string sEntityType = "";
 
                Session["PaymentID"] = value;
 
                LoadAccountInfo(Session["EntityType"].ToString(), (int)Session["EntityID"]);
                LoadPayment();
                rgDebits.Rebind();
            }
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            SetConnection();           
        }
 
        #region Events
 
        protected void chkApply_CheckedChanged(object sender, EventArgs e)
        {
            bool bHasRemainder = true;
            CheckBox chk = (CheckBox)sender;
            GridEditableItem edititem = (GridEditableItem)chk.Parent.Parent;
            try
            {
                TextBox txtRemainingAmount = (TextBox)edititem["RemainingAmount"].Controls[0];
     
                decimal decRemaining = LL_Utility.CurrencyToDecimal(lblPaymentRemaining.Text);
                decimal decAmountDue = LL_Utility.CurrencyToDecimal(txtRemainingAmount.Text);
                //TextBox txtAmountApplied = (TextBox)edititem["AmountApplied"].FindControl("txtAmountApplied");
                RadNumericTextBox txtAmountApplied = (RadNumericTextBox)edititem["AmountApplied"].FindControl("txtAmountApplied");
 
                #region Region Checked
                if (chk.Checked)
                {
                    if (decRemaining > decAmountDue)
                    {
                        if (txtAmountApplied.Text == "" || txtAmountApplied.Value == 0)
                        {
                            txtAmountApplied.Text = decAmountDue.ToString();
                        }
                        decRemaining = decRemaining - decAmountDue;
                        lblPaymentRemaining.Text = decRemaining.ToString("C2");
                        if (decRemaining > 0)
                        {
                            bHasRemainder = true;
                        }
                        else
                        {
                            bHasRemainder = false;
                        }
                    }
                    else if (decRemaining < decAmountDue)
                    {
                        txtAmountApplied.Text = decRemaining.ToString();
                        decRemaining = 0;
                        lblPaymentRemaining.Text = decRemaining.ToString("C2");
                        bHasRemainder = false;
                    }
 
                }
                #endregion Checked
 
                #region Region Unchecked
                else
                {
                    decRemaining = LL_Utility.CurrencyToDecimal(lblPaymentRemaining.Text);
 
                    //get the amount to be applied from the txtAmount textbox
                    decimal decAmountApplied = LL_Utility.CurrencyToDecimal(txtAmountApplied.Text);
                    decRemaining = decRemaining + decAmountApplied;
                    txtAmountApplied.Text = "";// 0.ToString("C2");
                    lblPaymentRemaining.Text = decRemaining.ToString("C2");
                    bHasRemainder = true;
 
                }
                #endregion Region Unchecked
                if (!bHasRemainder)
                {
                    foreach (GridItem item in rgDebits.EditItems)
                    {
                        GridDataItem dataitem = (GridDataItem)item;
                        CheckBox chkApply = (CheckBox)dataitem["Apply"].FindControl("chkApply");
                        RadNumericTextBox txtAmountApplied2 = (RadNumericTextBox)dataitem["AmountApplied"].FindControl("txtAmountApplied");
                        if (!chkApply.Checked)
                        {
                            chkApply.Enabled = false;
                            txtAmountApplied2.Enabled = false;
                        }
                    }
                }
                else
                {
                    foreach (GridItem item in rgDebits.EditItems)
                    {
                        GridDataItem dataitem = (GridDataItem)item;
                        CheckBox chkApply = (CheckBox)dataitem["Apply"].FindControl("chkApply");
                        RadNumericTextBox txtAmountApplied2 = (RadNumericTextBox)dataitem["AmountApplied"].FindControl("txtAmountApplied");
 
                        chkApply.Enabled = true;
                        txtAmountApplied2.Enabled = true;
                    }
                }
 
                //SetVisibility("Apply");
 
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }
 
        }
 
        protected void cmdApply_Click(object sender, EventArgs e)
        {
            ApplyCredit();
            rgDebits.Rebind();
        }
 
        private void ApplyCredit()
        {
            LaundryLogicDAL.ARApplicationsCollection oARAC = new LaundryLogicDAL.ARApplicationsCollection();
            LaundryLogicDAL.ARCredits oARC = new LaundryLogicDAL.ARCredits();
            LaundryLogicDAL.ARDebits oARD = new LaundryLogicDAL.ARDebits();
 
            try
            {
                oARAC.es.Connection.Name = "NAS";
                oARAC.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oARC.es.Connection.Name = "NAS";
                oARC.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oARD.es.Connection.Name = "NAS";
                oARD.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
 
                using (EntitySpaces.Interfaces.esTransactionScope scope = new esTransactionScope())
                {
                    foreach (GridItem item in rgDebits.EditItems)
                    {
                        GridEditableItem edititem = (GridEditableItem)item;
                        RadNumericTextBox txtAmountApplied = (RadNumericTextBox)edititem["AmountApplied"].FindControl("txtAmountApplied");
                        CheckBox chkApply = (CheckBox)edititem["Apply"].FindControl("chkApply");
                        decimal decAppliedAmount = LL_Utility.CurrencyToDecimal(txtAmountApplied.Text);
                        //int iCreditID = (int)ViewState["PaymentID"];
                        int iCreditID = (int)Session["PaymentID"];
                        int iDebitID = (int)edititem.OwnerTableView.DataKeyValues[edititem.ItemIndex]["ID"];
 
                        if (chkApply.Checked)
                        {
 
                            //check to see if the application exists for this credit and debit,
                            //and update the amounts if it does, otherwise add it.
 
                            oARAC.Query.Where(oARAC.Query.CreditID == iCreditID, oARAC.Query.DebitID == iDebitID);
                            if (oARAC.Query.Load())
                            {
                                oARAC[0].MarkAsDeleted();
                                oARAC.Save();
                            }
 
                            //Application Record
                            LaundryLogicDAL.ARApplications oARA = oARAC.AddNew();
                            oARA.CreditID = iCreditID;
                            oARA.DebitID = iDebitID;
                            oARA.Notes = "";
                            oARA.Amount = decAppliedAmount;
                            oARA.ApplicationDate = DateTime.Now;
                            oARA.IsVoid = false;
                            oARA.CreateDate = DateTime.Now;
                            oARA.CreatedBy = UserInfo.FullName;
                             
                            oARAC.Save();
                            //Credit Record
                            //Set Remaining Amount = Remaining Amount - decAppliedAmount
                            if (oARC.LoadByPrimaryKey(iCreditID))
                            {
                                oARC.RemainingAmount = oARC.RemainingAmount - decAppliedAmount;
                                oARC.Save();
                            }
 
                            //Debit Record
                            //Set Remaining Amount = Remaining Amount - decAppliedAmount
                            if (oARD.LoadByPrimaryKey(iDebitID))
                            {
                                oARD.RemainingAmount = oARD.RemainingAmount - decAppliedAmount;
                                oARD.Save();
                            }
                        }
                    }
 
                    scope.Complete();
 
                    //PlaceHolder phApplication = (PlaceHolder)cmdApply.Parent.Parent;
                    //phApplication.Visible = false;
 
                    //UserControl ucPayment = (UserControl)phApplication.Parent;
                    //PlaceHolder phPayment = (PlaceHolder)ucPayment.FindControl("phApplyPayments");
                    //phPayment.Visible = true;
                    //RadGrid rg = (RadGrid)ucPayment.FindControl("rgDebits");
                    //rg.Rebind();
                }
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
                //SetVisibility("Apply");
            }
            finally
            {
                oARAC.Dispose();
                oARAC = null;
                oARC = null;
                oARD = null;
            }
        }
         
        protected void cmdCancel_Click(object sender, EventArgs e)
        {
            LoadPayment();
            rgDebits.Rebind();
 
        }
 
        protected void rgDebits_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            DataTable oDTOpenDebits;
            DataTable oDTClosedDebits;
            DataTable oDT = new DataTable(); ;
            int iEntityID = 0;
            string sEntityType = "";
             
            try
            {
                if (Session["EntityID"] != null)
                {
                    iEntityID = (int)Session["EntityID"];
                    sEntityType = Session["EntityType"].ToString();
                }
 
 
                if (sEntityType != "" && iEntityID > 0)
                {
                    oDTOpenDebits = LoadOpenDebits(sEntityType, iEntityID);
                    oDTClosedDebits = LoadClosedDebits((int)Session["PaymentID"]);
                    oDT.Merge(oDTOpenDebits);
                    oDT.Merge(oDTClosedDebits);
                    if (oDT != null)
                    {
                        rgDebits.DataSource = oDT;
                    }
                    else
                    {
                        rgDebits.DataSource = new object[0];
                    }
                }
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
 
        protected void rgDebits_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item.ItemType == GridItemType.EditItem && e.Item.IsInEditMode)//check whether the grid is in edit mode
            {
                GridEditableItem editItem = (GridEditableItem)e.Item;
                CheckBox chkApply = (CheckBox)editItem["Apply"].FindControl("chkApply");
                RadNumericTextBox txtAmountApplied = (RadNumericTextBox)editItem["AmountApplied"].FindControl("txtAmountApplied");//accessing the textBox
 
                txtAmountApplied.AutoPostBack = true;
                txtAmountApplied.TextChanged += new EventHandler(txtAmountApplied_TextChanged);
            }
        }
 
        protected void rgDebits_SortCommand(object sender, GridSortCommandEventArgs e)
        {
            //SetRowsToEditMode();
        }
 
        protected void txtAmountApplied_TextChanged(object sender, EventArgs e)
        {
            bool bHasRemainder = true;
            RadNumericTextBox txt = (RadNumericTextBox)sender;
            GridEditableItem edititem = (GridEditableItem)txt.Parent.Parent;
 
            try
            {
                TextBox txtRemainingAmount = (TextBox)edititem["RemainingAmount"].Controls[0];
                decimal decPaymentAmount = LL_Utility.CurrencyToDecimal(lblPaymentAmount.Text);
                decimal decCurrentAppliedAmount = LL_Utility.CurrencyToDecimal(txt.Text);
                decimal decRemaining = LL_Utility.CurrencyToDecimal(lblPaymentRemaining.Text);
 
                decRemaining = 0;
 
                foreach (GridEditableItem editItem in rgDebits.EditItems)
                {
                    //GridEditableItem editItem = (GridEditableItem)item;
                    CheckBox chkApply = (CheckBox)editItem["Apply"].FindControl("chkApply");
                    RadNumericTextBox txtAmountApplied = (RadNumericTextBox)editItem["AmountApplied"].FindControl("txtAmountApplied");
                    if (chkApply.Checked)
                    {
                        decimal decTemp = LL_Utility.CurrencyToDecimal(txtAmountApplied.Text);
                        decRemaining = decRemaining + decTemp;
                    }
                }
 
                if (decRemaining > decPaymentAmount)
                {
                    txt.Text = "";
                    CheckBox chkApply = (CheckBox)edititem["Apply"].FindControl("chkApply");
                    chkApply.Checked = false;
                    //return;
                }
 
                if (decRemaining == decPaymentAmount)
                {
                    foreach (GridItem item in rgDebits.EditItems)
                    {
                        GridDataItem dataitem = (GridDataItem)item;
                        CheckBox chkApply = (CheckBox)dataitem["Apply"].FindControl("chkApply");
                        RadNumericTextBox txtAmountApplied2 = (RadNumericTextBox)dataitem["AmountApplied"].FindControl("txtAmountApplied");
                        if (!chkApply.Checked)
                        {
                            chkApply.Enabled = false;
                            txtAmountApplied2.Enabled = false;
                        }
                    }
                }
                else if (decRemaining < decPaymentAmount)
                {
                    foreach (GridItem item in rgDebits.EditItems)
                    {
                        GridDataItem dataitem = (GridDataItem)item;
                        CheckBox chkApply = (CheckBox)dataitem["Apply"].FindControl("chkApply");
                        RadNumericTextBox txtAmountApplied2 = (RadNumericTextBox)dataitem["AmountApplied"].FindControl("txtAmountApplied");
 
                        chkApply.Enabled = true;
                        txtAmountApplied2.Enabled = true;
                    }
                }
 
                //Recalculate
                decRemaining = 0;
                foreach (GridItem item in rgDebits.EditItems)
                {
                    GridEditableItem editItem2 = (GridEditableItem)item;
                    CheckBox chkApply2 = (CheckBox)editItem2["Apply"].FindControl("chkApply");
                    RadNumericTextBox txtAmountApplied2 = (RadNumericTextBox)editItem2["AmountApplied"].FindControl("txtAmountApplied");
                    if (chkApply2.Checked)
                    {
                        decimal decTemp = LL_Utility.CurrencyToDecimal(txtAmountApplied2.Text);
                        decRemaining = decRemaining + decTemp;
                    }
                }
                lblPaymentRemaining.Text = (decPaymentAmount - decRemaining).ToString("C2");
 
                //SetVisibility("Apply");
 
 
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(ex.Message, this, ex);
            }
 
        }
 
        #endregion Events
 
        #region Methods
 
        private void AutoApplyCredit(int iCreditID, int iEntityID, string sEntityType)
        {
            LaundryLogicDAL.ARDebitsCollection oARDC = new LaundryLogicDAL.ARDebitsCollection();
            LaundryLogicDAL.ARDebitsQuery oARDQ = new LaundryLogicDAL.ARDebitsQuery("ard");
            LaundryLogicDAL.ARAccountsQuery oARAQ = new LaundryLogicDAL.ARAccountsQuery("ara");
            LaundryLogicDAL.ARApplicationsCollection oARAC = new LaundryLogicDAL.ARApplicationsCollection();
 
            decimal decRemainingAmount = 0;
 
            try
            {
                oARDC.es.Connection.Name = "NAS";
                oARDC.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oARDQ.es2.Connection.Name = "NAS";
                oARDQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oARAC.es.Connection.Name = "NAS";
                oARAC.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oARAQ.es2.Connection.Name = "NAS";
                oARAQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
 
                //if standard account passed in
                if (sEntityType == "Standard")
                //get open debits for entity type and ID in descending order
                {
                    oARDQ.Where(
                        oARDQ.EntityID == iEntityID,
                        oARDQ.EntityType == sEntityType,
                        oARDQ.RemainingAmount > 0
                    );
 
                }
                //if master account, we need the sub accounts.
                else
                {
                    oARDQ.InnerJoin(oARAQ).On(
                        oARDQ.EntityType == "Standard" &&
                        oARDQ.EntityID == oARAQ.Id);
                    oARDQ.Where(
                        oARAQ.MasterAccountID == iEntityID,
                        oARDQ.RemainingAmount > 0
                        );
                }
                oARDQ.OrderBy(oARDQ.DebitDate.Ascending);
 
                if (oARDC.Load(oARDQ))
                {
 
 
                    //begin transaction
                    using (EntitySpaces.Interfaces.esTransactionScope scope = new esTransactionScope())
                    {
 
                        //for each debit
                        foreach (LaundryLogicDAL.ARDebits oARD in oARDC)
                        {
 
                            LaundryLogicDAL.ARCredits oARC = new LaundryLogicDAL.ARCredits();
 
                            try
                            {
 
                                oARC.es.Connection.Name = "NAS";
                                oARC.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
 
                                if (oARC.LoadByPrimaryKey(iCreditID))
                                {
                                    decimal decDebitRemainingAmount = (decimal)oARD.RemainingAmount;
 
                                    //if credit remaining amount > debit remaining amount
                                    if (oARC.RemainingAmount > oARD.RemainingAmount && oARD.RemainingAmount > 0)
                                    {
 
                                        //create application record with credit id and debit id and amount = debit remaining amount
                                        LaundryLogicDAL.ARApplications oARA = oARAC.AddNew();
                                        oARA.CreditID = iCreditID;
                                        oARA.DebitID = oARD.Id;
                                        oARA.Amount = decDebitRemainingAmount;
                                        oARA.ApplicationDate = DateTime.Today;
                                        oARA.CreateDate = DateTime.Now;
                                        oARA.CreatedBy = UserInfo.FullName;
                                        oARAC.Save();
                                        //update debit set remaining amount = 0
                                        oARD.RemainingAmount = 0;
                                        oARDC.Save();
                                        //update credit set remaining amount = credit original amount - debit original amount
                                        oARC.RemainingAmount = oARC.RemainingAmount - decDebitRemainingAmount;
                                        oARC.Save();
 
                                    }
 
 
                                    //if credit remaining amount < debit remaining amount
                                    else if (oARC.RemainingAmount < oARD.RemainingAmount && oARD.RemainingAmount > 0)
                                    {
                                        //create application record with credit id and debit id and amount = credit remaining amount
                                        LaundryLogicDAL.ARApplications oARA = oARAC.AddNew();
                                        oARA.CreditID = iCreditID;
                                        oARA.DebitID = oARD.Id;
                                        oARA.Amount = oARC.RemainingAmount;
                                        oARA.ApplicationDate = DateTime.Today;
                                        oARA.CreateDate = DateTime.Now;
                                        oARA.CreatedBy = UserInfo.FullName;
                                        oARAC.Save();
                                        //update debit set remaining amount = debit original amount - credit original amount
                                        if (oARC.RemainingAmount > 0)
                                        {
                                            oARD.RemainingAmount = decDebitRemainingAmount - oARC.RemainingAmount;
                                        }
                                        else
                                        {
                                            oARD.RemainingAmount = decDebitRemainingAmount - oARC.OriginalAmount;
                                        }
                                        //update credit set remaining amount = 0
                                        oARC.RemainingAmount = 0;
                                        oARC.Save();
 
                                        oARDC.Save();
 
 
                                    }
                                    //if credit remaining amount = debit remaining amount
                                    else if (oARC.RemainingAmount == oARD.RemainingAmount && oARD.RemainingAmount > 0)
                                    {
                                        //create application record with credit id and debit id and amount = credit remaining amount
                                        LaundryLogicDAL.ARApplications oARA = oARAC.AddNew();
                                        oARA.CreditID = iCreditID;
                                        oARA.DebitID = oARD.Id;
                                        oARA.Amount = oARC.RemainingAmount;
                                        oARA.ApplicationDate = DateTime.Today;
                                        oARA.CreateDate = DateTime.Now;
                                        oARA.CreatedBy = UserInfo.FullName;
                                        oARAC.Save();
                                        //update debit set remaining amount = 0
                                        oARD.RemainingAmount = 0;
                                        oARDC.Save();
                                        //update credit set remaining amount = 0
                                        oARC.RemainingAmount = 0;
                                        oARC.Save();
                                    }
 
                                    decRemainingAmount = (decimal)oARC.RemainingAmount;
 
                                }
                            }
                            finally
                            {
                                oARC = null;
                            }
                            if (decRemainingAmount == 0)
                            {
                                break;
                            }
                        }
 
                        //commit transaction
                        scope.Complete();
 
                    }
                }
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
                //SetVisibility("Apply");
            }
            finally
            {
                oARDC.Dispose();
                oARDC = null;
            }
        }
 
        public void LoadAccountInfo(string sEntityType, int iEntityID)
        {
            LaundryLogicDAL.ARAccounts oARA = new LaundryLogicDAL.ARAccounts();
            LaundryLogicDAL.ARMaster oARM = new LaundryLogicDAL.ARMaster();
 
            try
            {
                oARA.es.Connection.Name = "NAS";
                oARA.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oARM.es.Connection.Name = "NAS";
                oARM.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
 
                if (sEntityType == "Master")
                {
                    if (oARM.LoadByPrimaryKey(iEntityID))
                    {
                        lblAccountName.Text = oARM.AccountName;
                        lblAccountNumber.Text = "(N/A)";
                        lblIsMasterAccount.Text = "Y";
                    }
                }
                else if (sEntityType == "Standard")
                {
                    if (oARA.LoadByPrimaryKey(iEntityID))
                    {
                        lblAccountName.Text = oARA.AccountName;
                        lblAccountNumber.Text = oARA.Account;
                        lblIsMasterAccount.Text = "N";
                    }
                }
 
 
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }
            finally
            {
                oARA = null;
                oARM = null;
            }
        }
 
        private DataTable LoadClosedDebits(int iPaymentID)
        {
            LaundryLogicDAL.ARDebitsQuery oARDQ = new LaundryLogicDAL.ARDebitsQuery("ard");
            LaundryLogicDAL.ARAccountsQuery oARAQ = new LaundryLogicDAL.ARAccountsQuery("ara");
            LaundryLogicDAL.ARApplicationsQuery oARAQ2 = new LaundryLogicDAL.ARApplicationsQuery("ara2");
 
            try
            {
                oARDQ.es2.Connection.Name = "NAS";
                oARDQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oARAQ.es2.Connection.Name = "NAS";
                oARAQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oARAQ2.es2.Connection.Name = "NAS";
                oARAQ2.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
 
 
                oARDQ.Select(
                    oARDQ.Id,
                    oARDQ.DebitDate,
                    oARDQ.DebitIdentifier,
                    oARAQ.Account,
                    oARAQ.AccountName,
                    oARDQ.OriginalAmount,
                    oARDQ.RemainingAmount);
 
                oARDQ.InnerJoin(oARAQ).On(
                    oARDQ.EntityID == oARAQ.Id);
                oARDQ.InnerJoin(oARAQ2).On(
                    oARDQ.Id == oARAQ2.DebitID);
                oARDQ.Where(
                    oARAQ2.CreditID == iPaymentID,
                    oARDQ.RemainingAmount == 0
                );
 
                oARDQ.OrderBy(oARDQ.DebitDate.Ascending);
 
                return oARDQ.LoadDataTable();
 
            }
            catch (Exception ex)
            {
                System.Text.StringBuilder oSB = new System.Text.StringBuilder();
                oSB.AppendLine("Missing variable:");
                oSB.AppendLine("iPaymentID: " + iPaymentID);
 
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(oSB.ToString(), this, ex);
                return null;
            }
            finally
            {
                oARDQ = null;
                oARAQ = null;
            }
 
        }
 
        private DataTable LoadOpenDebits(string sEntityType, int iEntityID)
        {
            LaundryLogicDAL.ARDebitsQuery oARDQ = new LaundryLogicDAL.ARDebitsQuery("ard");
            LaundryLogicDAL.ARAccountsQuery oARAQ = new LaundryLogicDAL.ARAccountsQuery("ara");
            try
            {
                oARDQ.es2.Connection.Name = "NAS";
                oARDQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oARAQ.es2.Connection.Name = "NAS";
                oARAQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
 
                oARDQ.Select(
                    oARDQ.Id,
                    oARDQ.DebitDate,
                    oARDQ.DebitIdentifier,
                    oARAQ.Account,
                    oARAQ.AccountName,
                    oARDQ.OriginalAmount,
                    oARDQ.RemainingAmount);
 
                if (sEntityType == "Standard")
                {
                    oARDQ.InnerJoin(oARAQ).On(oARDQ.EntityID == oARAQ.Id);
                    oARDQ.Where(
                        oARDQ.EntityID == iEntityID,
                        oARDQ.EntityType == sEntityType,
                        oARDQ.RemainingAmount > 0,
                        oARDQ.OriginalAmount > 0
                    );
                }
                else
                {
                    oARDQ.InnerJoin(oARAQ).On(
                        oARDQ.EntityID == oARAQ.Id);
                    oARDQ.Where(
                        oARAQ.MasterAccountID == iEntityID,
                        oARDQ.RemainingAmount > 0,
                        oARDQ.OriginalAmount > 0
                    );
                }
                oARDQ.OrderBy(oARDQ.DebitDate.Ascending);
 
                return oARDQ.LoadDataTable();
 
            }
            catch(Exception ex)
            {
                System.Text.StringBuilder oSB = new System.Text.StringBuilder();
                oSB.AppendLine("Missing variable:");
                oSB.AppendLine("iEntityID: " + iEntityID);
                oSB.AppendLine("sEntityType: " + sEntityType);
 
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(oSB.ToString(), this, ex);
                return null;
            }
            finally
            {
                oARDQ = null;
                oARAQ = null;
            }
        }
 
        private void LoadPayment()
        {
            LaundryLogicDAL.ARCredits oARC = new LaundryLogicDAL.ARCredits();
            LaundryLogicDAL.ARActivityType oART = new LaundryLogicDAL.ARActivityType();
            try
            {
                oARC.es.Connection.Name = "NAS";
                oARC.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oART.es.Connection.Name = "NAS";
                oART.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
 
 
                //if (oARC.LoadByPrimaryKey((int)ViewState["PaymentID"]))
                if (oARC.LoadByPrimaryKey((int)Session["PaymentID"]))
                {
                    if (oART.LoadByPrimaryKey((int)oARC.ActivityTypeID))
                    {
                        this.lblPaymentActivityType.Text = oART.ActivityType;
                    }
                    this.lblCreditIdentifier.Text = oARC.CreditIdentifier;
                    DateTime dteCreditDate = (DateTime)oARC.CreditDate;
                    this.lblCreditDate.Text = dteCreditDate.ToShortDateString();
                    this.lblPaymentAmount.Text = string.Format("{0:C2}", oARC.OriginalAmount);
                    this.lblPaymentRemaining.Text = string.Format("{0:C2}", oARC.RemainingAmount);
                    if (oARC.RemainingAmount > 0)
                    {
                        //btnAutoApply.Enabled = true;
                         
                    }
                    else
                    {
                        //btnAutoApply.Enabled = false;
                    }
                }
 
            }
            catch(Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }
            finally
            {
                oARC = null;
                oART = null;
            }
        }
 
        private void RollbackCredit(int iID)
        {
            LaundryLogicDAL.ARApplicationsCollection oARAC = new LaundryLogicDAL.ARApplicationsCollection();
            LaundryLogicDAL.ARDebits oARD = new LaundryLogicDAL.ARDebits();
            LaundryLogicDAL.ARCredits oARC = new LaundryLogicDAL.ARCredits();
            try
            {
                string sCreditIdentifier = "";
 
                oARAC.es.Connection.Name = "NAS";
                oARAC.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oARD.es.Connection.Name = "NAS";
                oARD.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oARC.es.Connection.Name = "NAS";
                oARC.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
 
                //Get all applications with the Credit ID = iID
                oARAC.Query.Where(
                    oARAC.Query.CreditID == iID
                );
 
 
                if (oARAC.Query.Load())
                {
                    //begin transaction
                    using (esTransactionScope scope = new esTransactionScope())
                    {
                        //for each application record
                        for (int i = 0; i < oARAC.Count; i++)
                        {
                            //get invoice record
                            if (oARD.LoadByPrimaryKey((int)oARAC[i].DebitID))
                            {
                                //update invoice record set remaining amount = remaining amount + application amount
                                oARD.RemainingAmount = oARD.RemainingAmount + oARAC[i].Amount;
                                oARD.Save();
                            }
 
                            //get credit record
                            if (oARC.LoadByPrimaryKey(iID))
                            {
                                //update credit record set remaining amount = remaining amount + application amount
                                oARC.RemainingAmount = oARC.RemainingAmount + oARAC[i].Amount;
                                sCreditIdentifier = oARC.CreditIdentifier;
                                oARC.Save();
                            }
                        }
                        oARAC.MarkAllAsDeleted();
                        oARAC.Save();
 
                        scope.Complete();
                    }
                }
                //else
                //{
                //    if (oARC.LoadByPrimaryKey(iID))
                //    {
                //        //update credit record set remaining amount = remaining amount + application amount
                //        oARC.RemainingAmount = oARC.RemainingAmount + oARAC[i].Amount;
                //        sCreditIdentifier = oARC.CreditIdentifier;
                //        //oARC.MarkAsDeleted();
                //        oARC.Save();
                //    }
                //}
                //commit transaction
 
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }
            finally
            {
                oARAC.Dispose();
                oARAC = null;
                oARC = null;
                oARD = null;
            }
        }
 
        private void SetConnection()
        {
            //If there is no default connection named DNNFulcrum
            if (esConfigSettings.ConnectionInfo.Default != "DNNFulcrum")
            {
                //Get the connectionInfo section from the web.config
                esConfigSettings ConnectionInfoSettings = esConfigSettings.ConnectionInfo;
                //loop through each connection...
                foreach (esConnectionElement connection in ConnectionInfoSettings.Connections)
                {
                    //if there is a DNNFulcrum in es connections set it default
                    if (connection.Name == "DNNFulcrum")
                    {
                        esConfigSettings.ConnectionInfo.Default = connection.Name;
                        return;
                    }
                }
            }
            // Register the Loader
            esProviderFactory.Factory = new EntitySpaces.LoaderMT.esDataProviderFactory();
        }
 
        private void SetRowsToEditMode()
        {
            //try
            //{
            //    for (int i = 0; i < rgDebits.PageSize; i++)
            //    {
            //        rgDebits.EditIndexes.Add(i);
            //    }
 
            //}
            //catch(Exception ex)
            //{
            //    DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            //}
        }
 
        private void SetVisibility(string sFunction)
        {
            //System.Web.UI.UserControl ucPayments = (System.Web.UI.UserControl)this.Parent.Parent;
            //PlaceHolder phAccounts = (PlaceHolder)ucPayments.FindControl("phAccounts");
            //PlaceHolder phCredits = (PlaceHolder)ucPayments.FindControl("phCredits");
            //PlaceHolder phApplyPayments = (PlaceHolder)ucPayments.FindControl("phApplyPayments");
            //System.Web.UI.UserControl ucCredits = (System.Web.UI.UserControl)phCredits.FindControl("Credits1");
            //RadGrid rgCredits = (RadGrid)ucCredits.FindControl("rgCredits");
            //rgCredits.Rebind();
 
            //switch (sFunction)
            //{
            //    case "Customer":
            //        {
            //            phAccounts.Visible = true;
            //            phCredits.Visible = false;
            //            phApplyPayments.Visible = false;
            //            break;
 
            //        }
            //    case "Payment":
            //        {
            //            phAccounts.Visible = false;
            //            phCredits.Visible = true;
            //            phApplyPayments.Visible = false;
            //            break;
 
            //        }
            //    case "Apply":
            //        {
            //            phAccounts.Visible = false;
            //            phCredits.Visible = false;
            //            phApplyPayments.Visible = true;
            //            break;
            //        }
            //}
        }
 
        #endregion Methods
 
        protected void btnClearAll_Click(object sender, EventArgs e)
        {
            ClearAll();
            //SetVisibility("Apply");
        }
 
        private void ClearAll()
        {
            foreach (GridItem item in rgDebits.EditItems)
            {
                GridDataItem dataitem = (GridDataItem)item;
                CheckBox chkApply = (CheckBox)dataitem["Apply"].FindControl("chkApply");
                RadNumericTextBox txtAmountApplied = (RadNumericTextBox)dataitem["AmountApplied"].FindControl("txtAmountApplied");
                chkApply.Checked = false;
                txtAmountApplied.Text = "";
            }
            //lblPaymentRemaining.Text = lblPaymentAmount.Text;
        }
 
        protected void btnAutoApply_Click(object sender, EventArgs e)
        {
            if (Session["EntityType"] != null &&
                Session["EntityID"] != null &&
                Session["PaymentID"] != null)
            {
                string sEntityType = Session["EntityType"].ToString();
                int iEntityID = (int)Session["EntityID"];
                int iCreditID = (int)Session["PaymentID"];
                AutoApplyCredit(iCreditID, iEntityID, sEntityType);
                LoadPayment();
                rgDebits.Rebind();
                ClearAll();
                //SetVisibility("Apply");
            }
        }
 
        protected void btnRollbackAll_Click(object sender, EventArgs e)
        {
            if(Session["PaymentID"] != null)
            {
                int iPaymentID = (int)Session["PaymentID"];
                RollbackCredit(iPaymentID);
                rgDebits.Rebind();
                ClearAll();
            }
 
        }
 
        protected void rgDebits_PreRender(object sender, EventArgs e)
        {
            try
            {
                for (int i = 0; i < rgDebits.PageSize; i++)
                {
                    rgDebits.EditIndexes.Add(i);
                }
 
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }
 
        }
 
        protected void btnRollbackSelected_Click(object sender, EventArgs e)
        {
            foreach (GridEditableItem oEditItem in rgDebits.MasterTableView.Items)
            {
                CheckBox chkApply = (CheckBox)oEditItem.FindControl("chkApply");
                if (chkApply.Checked)
                {
                    int iApplicationID = (int)oEditItem.OwnerTableView.DataKeyValues[oEditItem.ItemIndex]["ID"];
                    RollbackApplication((int)Session["PaymentID"], iApplicationID);
                }
            }
            LoadPayment();
            rgDebits.Rebind();
            UpdatePanel oUP = (UpdatePanel)this.Parent.Parent;
            oUP.Update();
        }
 
        private void RollbackApplication(int iCreditID, int iDebitID)
        {
            //need to get the creditID and debit ID from the application record, then
            //add the applied amount to the credit remaining amount
            //add the applied amount to the debit remaining amount
            //delete the application
 
            LaundryLogicDAL.ARApplications oARA = new LaundryLogicDAL.ARApplications();
            LaundryLogicDAL.ARDebits oARD = new LaundryLogicDAL.ARDebits();
            LaundryLogicDAL.ARCredits oARC = new LaundryLogicDAL.ARCredits();
            try
            {
                string sCreditIdentifier = "";
 
                oARA.es.Connection.Name = "NAS";
                oARA.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oARD.es.Connection.Name = "NAS";
                oARD.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
                oARC.es.Connection.Name = "NAS";
                oARC.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
 
                //Get all applications with the Credit ID = iID
 
                oARA.Query.Where(oARA.Query.CreditID == iCreditID, oARA.Query.DebitID == iDebitID);
                if (oARA.Query.Load())
                {
                    //begin transaction
                    using (esTransactionScope scope = new esTransactionScope())
                    {
                        //get invoice record
                        if (oARD.LoadByPrimaryKey((int)oARA.DebitID))
                        {
                            //update invoice record set remaining amount = remaining amount + application amount
                            oARD.RemainingAmount = oARD.RemainingAmount + oARA.Amount;
                            oARD.Save();
                        }
 
                        //get credit record
                        if (oARC.LoadByPrimaryKey((int)oARA.CreditID))
                        {
                            //update credit record set remaining amount = remaining amount + application amount
                            oARC.RemainingAmount = oARC.RemainingAmount + oARA.Amount;
                            sCreditIdentifier = oARC.CreditIdentifier;
                            oARC.Save();
                        }
                         
                        oARA.MarkAsDeleted();
                        oARA.Save();
 
                        scope.Complete();
                    }
                }
 
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }
            finally
            {
                oARA = null;
                oARC = null;
                oARD = null;
            }
 
        }
 
    }
}
Genti
Telerik team
 answered on 28 Jul 2011
1 answer
571 views
hi i am using windowmanager and radwindow to popup one div from same page.

i am able to display div as popup. but now i have one button on popup and onclicking which popuo window should close.

i tried most solutions which i got in forum but none is working.

<telerik:RadWindowManager ID="winmanParolee" runat="server" ReloadOnShow="false"
            VisibleOnPageLoad="false" KeepInScreenBounds="true">
            <Windows>
                <telerik:RadWindow ID="winPopup" runat="server" OpenerElementID="Button1" ShowContentDuringLoad="true"
                    KeepInScreenBounds="true" Modal="true" Width="600px" Height="400px">
                    <ContentTemplate>
                    <script type= "text/javascript">
                     
                         function Close() {
                                GetRadWindow().Close();
                            }    
  
                            function GetRadWindow() {
                                var oWindow = null;
                                if (window.radWindow)
                                    oWindow = window.radWindow; 
                                else if (window.frameElement.radWindow)
                                    oWindow = window.frameElement.radWindow;       
                                return oWindow;
                            }
                               
                         </script>
                        <div>
                            My dialog content here...
                            <telerik:RadSchedulerRecurrenceEditor ID="RadSchedulerRecurrenceEditor1" runat="server">
                            </telerik:RadSchedulerRecurrenceEditor>
                            <asp:Button ID="Button3" runat="server" Text="Close" OnClick="close_click" />
                        </div>
                    </ContentTemplate>
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>

and on server side i tried both options but not able to work .

protected void close_click(object sender, EventArgs e)
       {
                     Label1.Text = "<script type='text/javascript'>Close()</" + "script>";
           
          // Page.ClientScript.RegisterStartupScript(this.GetType(), "", "Close()",true);
       }

waiting for your reply.

Thanks in advance
Marin Bratanov
Telerik team
 answered on 28 Jul 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?