custom footer template on gridview

4 posts, 0 answers
  1. cielo valdoz
    cielo valdoz avatar
    33 posts
    Member since:
    Dec 2009

    Posted 06 Oct 2010 Link to this post

    Hi,

    I wanna display totals at the footer of gridview, but it returns empty even if im binding the data from database.
    I'm not sure if footer template can accept this code:

     

     


    <
    FooterTemplate>

     

     

     

    <asp:Label ID="lblTotalQty" runat="server" Text='<%# Eval("Total") %>'></asp:Label>

     

     

     

    <br />

     

     

     

    <asp:Label ID="lblTotalQtyF" runat="server" Text='<%# Eval("TotalF") %>'></asp:Label>

     

     

     

    </FooterTemplate>

     



    <telerik:GridTemplateColumn HeaderText="Qty Sold" UniqueName="QuantitySold" ItemStyle-Width="70" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Center">
                                                               <FooterTemplate>
                                                                   <asp:Label ID="lblTotalQty" runat="server" Text='<%# Eval("Total") %>'></asp:Label>
                                                                   <br />
                                                                   <asp:Label ID="lblTotalQtyF" runat="server" Text='<%# Eval("TotalF") %>'></asp:Label>
                                                               </FooterTemplate>
                                                               <ItemTemplate>
                                                                    <asp:Label ID="lblQtySold" runat="server" Text='<%# Eval("QtySold") %>'></asp:Label><br />
                                                                    <asp:Label ID="lblQtySoldF" runat="server" Text='<%# Eval("QtySoldF") %>'></asp:Label>
                                                               </ItemTemplate>
                                                               <HeaderStyle HorizontalAlign="Center" />
                                                               <ItemStyle HorizontalAlign="Right" />
                                                          </telerik:GridTemplateColumn>

    Thanks,
    Cielo
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Oct 2010 Link to this post

    Hello,


    Accessing control inside the FooterTemplate can be done in the following way.

    CS:
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridFooterItem)
        {
            GridFooterItem footerItem = (GridFooterItem)e.Item;
            Label lbl = (Label)footerItem.FindControl("LblTotalQty");
        }
    }


    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. cielo valdoz
    cielo valdoz avatar
    33 posts
    Member since:
    Dec 2009

    Posted 06 Oct 2010 Link to this post

    Hi,

    I can access the footer template at ItemDatabound
    If (TypeOf e.Item Is GridFooterItem) Then
              Dim footerItem As GridFooterItem = DirectCast(e.Item, GridFooterItem)
              Dim lblTotalQtySold As Label = footerItem.FindControl("lblTotalQty")
    End If

    But the value is empty. I checked the datatable wherein i bind and it has value.

    <asp:Label ID="lblTotalQty" runat="server" Text='<%# Eval("Total") %>'></asp:Label>

  5. Martin
    Admin
    Martin avatar
    811 posts

    Posted 11 Oct 2010 Link to this post

    Hello Cielo valdoz,

    I am afraid that binding expressions are not supported for template columns footer template. To verify this you can try setting a binding expression in a footer template of a standard GridView's TemplateField.

    I hope this helps.

    Regards,
    Martin
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top