This is a migrated thread and some comments may be shown as answers.

custom footer template on gridview

3 Answers 451 Views
Grid
This is a migrated thread and some comments may be shown as answers.
cielo valdoz
Top achievements
Rank 1
cielo valdoz asked on 06 Oct 2010, 06:48 AM
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

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 06 Oct 2010, 08:29 AM
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.
0
cielo valdoz
Top achievements
Rank 1
answered on 06 Oct 2010, 08:49 AM
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>

0
Martin
Telerik team
answered on 11 Oct 2010, 08:18 AM
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
Tags
Grid
Asked by
cielo valdoz
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
cielo valdoz
Top achievements
Rank 1
Martin
Telerik team
Share this question
or