Find Gridview Footer Row
-
I have to Find Gridview Footer Row in Javascript. Is there any chance to show/hide footer row in javascript. How to Find Label in Footer Row.
-
I have to Find Gridview Footer Row in Javascript. Is there any chance to show/hide footer row in javascript. How to Find Label in Footer Row.
Here's one way to do it: 1) You need to give your gridview footer row an ID. You can do this in RowCreated (sorry it's VB, that's the project I had open at the moment :)):
Protected Sub gvT\_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvT.RowCreated If e.Row.RowType = DataControlRowType.Footer Then e.Row.ID = "theFooter" End If End Sub
This will give you a footer row like <tr id='ctl00_gvT_theFooter'> Now to get at it using javascript do something like:
function toggleFooter() { var ftr = document.getElementById('<%=gvT.ClientID %>\_theFooter'); if (ftr.style.display != 'none') ftr.style.display = 'none'; else ftr.style.display = ''; }
- If you're using templatefields in your grid view something like:
<asp:gridview id="gvT" runat="server" showfooter="true" autogeneratecolumns="false">
<columns>
asp:templatefield
<itemtemplate>
<%#Eval("MyField") %>
</itemtemplate>
<footertemplate>
<asp:label id="lblFooterLabel1" runat="server"></asp:label>
</footertemplate>
</asp:templatefield>
</columns>
</asp:gridview>You can access it using:
function getFooterLabel() { var lbl = document.getElementById('&<%=gvT.ClientID %>\_theFooter\_lblFooterLabel1'); return lbl; }
- S 50 cups of coffee and you know it's on! Code, follow, or get out of the way.