Why can't I databind with a column using aggregate

2 posts, 1 answers
  1. William
    William avatar
    13 posts
    Member since:
    Oct 2018

    Posted 19 Oct 2018 Link to this post

    Everything works fine, but as soon as I try to use Aggregate and FooterAggregateFormatString, it comes up with a target invocation exception on my databind line.  Am I supposed to do it a different way?

    My aspx file has:

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1" UpdateInitiatorPanelsOnly="true">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="myRadGrid">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="myRadGrid" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadGrid ClientSettings-Scrolling-ScrollHeight="500" ShowFooter="true" ClientSettings-Scrolling-AllowScroll="true" ClientSettings-Scrolling-UseStaticHeaders="true" RenderMode="Lightweight" OnSortCommand="SortCommand" AllowSorting="true" ID="myRadGrid" runat="server"  EnableEmbeddedSkins="False">
            <ItemStyle BackColor="#E2E4FF" Font-Size="10" />
            <AlternatingItemStyle Font-Size="10" />
            <HeaderStyle CssClass="CustomHeader" BorderStyle="Solid" BorderWidth="1" BorderColor="Black" HorizontalAlign="Center" Font-Size="12" />
            <MasterTableView AutoGenerateColumns="false" TableLayout="Fixed">
                <Columns>
                    <telerik:GridTemplateColumn SortExpression="load_seconds" Aggregate="Sum" FooterAggregateFormatString="Total Seconds: {0}" HeaderButtonType="TextButton" HeaderStyle-Width="14%" HeaderText="Load Seconds">
                        <ItemTemplate>
                            <%#String.Format("{0}", Eval("load_seconds")) %>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
                <EditFormSettings>
                    <EditColumn CancelImageUrl="Cancel.gif" InsertImageUrl="Update.gif" UpdateImageUrl="Update.gif">
                    </EditColumn>
                </EditFormSettings>
            </MasterTableView>
            <HeaderStyle CssClass="CustomHeader"></HeaderStyle>
            <FilterMenu RenderMode="Lightweight"></FilterMenu>
            <HeaderContextMenu RenderMode="Lightweight"></HeaderContextMenu>
        </telerik:RadGrid>

    and my aspx.vb files has:

    Protected Sub loadData()
            lbl_errormsg.Text = ""
            Dim bEffDt As Date
            Dim eEffDt As Date
            Dim begEffDt As String = ""
            Dim endEffDt As String = ""
            bEffDt = Beg_Date.SelectedDate
            eEffDt = End_Date.SelectedDate
            begEffDt = bEffDt.ToString("yyyy/MM/dd")
            endEffDt = eEffDt.ToString("yyyy/MM/dd")
            Try
                myRadGrid.DataSource = FastSQL.SelectQuery("myDB", "my select statement")
            Catch ex As Exception
                lbl_errormsg.Text = "There was an error."
            End Try
            myRadGrid.DataBind()
        End Sub

    with Page_load calling loadData()

  2. Answer
    Eyup
    Admin
    Eyup avatar
    3645 posts

    Posted 23 Oct 2018 Link to this post

    Hello William,

    To resolve this issue, you can switch to declarative binding or NeedDataSource binding as suggested in the following article:
    https://www.telerik.com/support/kb/aspnet-ajax/grid/details/how-to-bind-radgrid-properly-on-server-side

    In addition, you can also check:
    https://www.telerik.com/support/kb/aspnet-ajax/ajaxmanager/details/get-more-descriptive-errors-by-disabling-ajax

    I hope this will prove helpful.

    Regards,
    Eyup
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top