GridView Cells may not remember the style you set like this on PostBack.
ShowFooter will only affect what DataBind does. So it must be set before the call to DataBind.
Superguppie.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
shumailaAjk
Member
620 Points
380 Posts
how to hide some cells of footer row
May 07, 2012 12:56 PM|LINK
i want to show some cells of footer row from code behind how to do??
bbcompent1
All-Star
33097 Points
8529 Posts
Moderator
Re: how to hide some cells of footer row
May 07, 2012 05:39 PM|LINK
Show your code please :) Sorry, crystal ball is in the shop. ;)
shumailaAjk
Member
620 Points
380 Posts
Re: how to hide some cells of footer row
May 08, 2012 03:20 AM|LINK
here is my design code
<asp:GridView ID="gvRequestDetail" runat="server" ShowFooter="true" AutoGenerateColumns="False" OnRowCommand="gvRequestDetail_RowCommand" DataSourceID="RequestDetailsDS"> <Columns> <asp:TemplateField HeaderText="Distribution List Name"> <ControlStyle Width="15%"></ControlStyle> <FooterTemplate> <asp:TextBox ID="txtlistname" runat="server" Enabled="false" SkinID="InputTextbox" Text=""></asp:TextBox> <asp:Button ID="btn_dlist" runat="server" Text="..." OnClientClick="return OpenRetDialogDistributionName('ctl00_ContentPlaceHolder1_gvRequestDetail_ctl03_txtlistname','ctl00_ContentPlaceHolder1_hfdlistid','ctl00_ContentPlaceHolder1_hfdlistname');" CausesValidation="False" Height="20px"></asp:Button> </FooterTemplate> <ItemTemplate> <asp:Label ID="lbl_distributionlist" Width="30%" runat="server" Text='<%# Bind("D_Name") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Approval"> <AlternatingItemTemplate> <asp:LinkButton ID="lnkApprove" runat="server" SkinID="grdlnkBtnWhite" CommandName="Approve" CommandArgument='<%# Eval("D_requestdetailID") %>'>Approve</asp:LinkButton> </AlternatingItemTemplate> <FooterTemplate> <asp:LinkButton ID="lbtnAppAll" runat="server" CommandName="Approve All">Approve All</asp:LinkButton> </FooterTemplate> <ItemStyle Width="12%"></ItemStyle> <ItemTemplate> <asp:LinkButton ID="lnkApprove" runat="server" CommandName="Approve" CommandArgument='<%# Eval("D_requestdetailID") %>'>Approve</asp:LinkButton> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Rejection"> <AlternatingItemTemplate> <asp:LinkButton ID="lnkReject" runat="server" SkinID="grdlnkBtnWhite" CommandName="Reject" CommandArgument='<%# Eval("D_requestdetailID") %>'>Reject</asp:LinkButton> </AlternatingItemTemplate> <FooterTemplate> <asp:LinkButton ID="lBtnRejectAll" runat="server" CommandName="Reject All">Reject All</asp:LinkButton> </FooterTemplate> <ItemStyle Width="10%"></ItemStyle> <ItemTemplate> <asp:LinkButton ID="lnkReject" runat="server" CommandName="Reject" CommandArgument='<%# Eval("D_requestdetailID") %>'>Reject</asp:LinkButton> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>and in this way i am trying to show and hide cells but not working..i am calling this method in pageload grirview related paert is here
gvRequestDetail.DataSourceID = ""; gvRequestDetail.DataSource=oDs.D_requests_details; gvRequestDetail.DataBind(); gvRequestDetail.ShowFooter = true; gvRequestDetail.FooterRow.Cells[0].Style.Add("display", "none"); gvRequestDetail.FooterRow.Cells[1].Style.Add("display", "none"); gvRequestDetail.FooterRow.Cells[2].Style.Add("display", "none");2pac
Participant
1586 Points
269 Posts
Re: how to hide some cells of footer row
May 08, 2012 03:42 AM|LINK
Hi
// Gets the footer row directly GridViewRow row = gvRequestDetail.FooterRow;//you can find any control in footer like this var listName = ((TextBox)row.FindControl("txtlistname")).Text;Hope this helps
Regards,
Jayesh
tusharrs
Contributor
3230 Points
668 Posts
Re: how to hide some cells of footer row
May 08, 2012 03:59 AM|LINK
make false here in the higlighted line
1) gvRequestDetail.ShowFooter= false;
gvRequestDetail.FooterRow.Cells[0].Style.Add("display","none");
gvRequestDetail.FooterRow.Cells[1].Style.Add("display","none");
gvRequestDetail.FooterRow.Cells[2].Style.Add("display","none");
2) also remove showfooter = true in the design
( Mark as Answer if it helps you out )
View my Blog
mahedee
Member
450 Points
116 Posts
Re: how to hide some cells of footer row
May 08, 2012 04:37 AM|LINK
this.gvRequestDetail.FooterRow.Cells[0].Style.Add("visibility", "hidden"); //For invisible this.gvRequestDetail.FooterRow.Cells[0].Style.Add("visibility", "visible"); //For visibleMahedee
Blog: http://mahedee.blogspot.com
shumailaAjk
Member
620 Points
380 Posts
Re: how to hide some cells of footer row
May 08, 2012 06:05 AM|LINK
ENOUGH :-( every solution works once...i have saved every thing but when i compile and execute code again it stop working
what to do...
superguppie
All-Star
48225 Points
8679 Posts
Re: how to hide some cells of footer row
May 11, 2012 03:22 PM|LINK
Do you DataBind only when !IsPostBack?
And what about adding the style?
GridView Cells may not remember the style you set like this on PostBack.
ShowFooter will only affect what DataBind does. So it must be set before the call to DataBind.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.