Hi,
How can I access label and set the value of the label which is placed inside footertemplate dynamically in server side code?
<FooterTemplate>
<asp:Label Text="" runat="server" ID="lblTotal" CssClass=""/>
<asp:Label Text="" runat="server" ID="lblblank"/>
</FooterTemplate>
c# code
PAGrid.DataSource = ds;
PAGrid.DataBind();
((
._totalActiveIR].Footer.FindControl("lblTotal")).Text = "Dynamic".
But the code in c# is returning null.(It can not find the control.
Is there in sample code where someone have impltemented the same stuff?
Please help me out.
Thanks,
Sanjay
Hello Sanjay,
Thank you for posting in the community.
In order to access the templated footer control, the column should be cast to its precise respective field type and the templated controls accessed through the footer's template container. For instance for a BoundDataField:
((Infragistics.Web.UI.GridControls.BoundDataField)(WebDataGrid1.Columns[0])).Footer.TemplateContainer.FindControl("Label2")
Please let me know if this helps.
Please feel free to contact me if you have any further questions regarding this matter.
Hi Petar,
I tried but that didn't work. I have included aspx and c# code please have a look and let me know where I'm doing anything wrong.
in ASPX :
<ig:TemplateDataField Key="PrincipalGRP" Header-Text="Principal" Header-CssClass="igg_centerAlign" Footer-CssClass="perfFooterClass" CssClass="cellBorder"> <ItemTemplate> <div style="text-align:right;float:left;width:43%;"> <%#Eval("PRINCIPAL_COUNT")%> </div> <div style="text-align:right;"> (<%#Eval("PRINCIPAL_PCT")%>%) </div> </ItemTemplate> <FooterTemplate> <asp:Label ID="lblPrincipal" runat="server" Text=""></asp:Label> <asp:Label ID="lblPrincipalPCT" runat="server" Text=""></asp:Label> </FooterTemplate></ig:TemplateDataField>
in C# :
(Label)(((Infragistics.Web.UI.GridControls.TemplateDataField)(GEGrid.Columns[2])).Footer.TemplateContainer.FindControl("lblPrincipal"));
But it always returns null. I'm not able to get the object of label so that I can set the value of footer dynamically.
Can you check this and help me out?
Hello there,
I have the same issue, but cant find a solution:
c#
private const string COL_ROLETYPE = "RoleType";
{#warning todo evtl. Refresh auf Daten } else { fillRoleTypes(dgrRoles.Columns[COL_ROLETYPE].Footer.TemplateContainer.FindControl("ddlRoleType") as DropDownList, true); dgrRoles.ShowFooter = true; }
ASP.Net
<ig:TemplateDataField Key="RoleType" Width="160px" Footer-CssClass="rowSelectEdit"> <HeaderTemplate> <asp:Label ID="lblRoletypeHeader" runat="server">Roletype</asp:Label><br> <asp:ImageButton ID="ibutSortAzRoleType" runat="server" CssClass="icoButton" CausesValidation="False" ImageUrl="Images/base/Icons/12x12/sort_ascending.png" CommandArgument="RoletypeAZ" CommandName="Sort"></asp:ImageButton> <asp:ImageButton ID="ibutSortRoleTypeZA" runat="server" CssClass="icoButton" CausesValidation="False" ImageUrl="Images/base/Icons/12x12/sort_descending.png" CommandArgument="RoletypeZA" CommandName="Sort"></asp:ImageButton> </HeaderTemplate> <ItemTemplate> <%--<ig:BoundDataField Style="white-space: normal" Width="120px" DataFieldName="RoletypeDescription" Key="RoletypeDescription" Hidden="false" /> --%> <div style="width: 120px;"> <asp:Label ID="lblRoletype" Text='<%# Bind("RoletypeDescription") %>' runat="server" Style="white-space: normal">Label</asp:Label> </div> </ItemTemplate> <FooterTemplate> <%--<div style="width: 160px; padding-left: 3px;padding-right: 1px;">--%> <stgwc:DropDown ID="ddlRoleType" DisplayMode="DropDownList" TextField="RoleType" ValueField="RoleType" runat="server" Width="150px" ValidationGroup="EditRole" EnableDropDownAsChild="true" DropDownItemBinding-ValueField="RoleTypeCode" DropDownItemBinding-TextField="RoletypeDescription" > </stgwc:DropDown> </FooterTemplate> </ig:TemplateDataField>
Another problem is aswell, that the Footer-CssClass seems to be ignored.