Solved

Hide Gridview(vb) Column using javascript

Posted on 2016-08-01
2
80 Views
Last Modified: 2016-08-01
Could someone assist me with hiding a grid view column when the page load using java script.  I don't want to make the columns invisible as I need to read the data when the page loads.    Thanks



<asp:GridView ID="gvLiveLearners" runat="server" DataSourceID="dsLiveLeaners" AutoGenerateColumns="False" CssClass="tableAc" DataKeyNames="PROGRESS_RAG">
                        <Columns>
                            <asp:BoundField DataField="FULLNAME" HeaderText="FULLNAME" SortExpression="FULLNAME" />
                            <asp:BoundField DataField="SECTOR" HeaderText="Route" SortExpression="SECTOR" />
                            <asp:BoundField DataField="SCHEME" HeaderText="Level" SortExpression="SCHEME" />
                            <asp:BoundField DataField="LATEST_REVIEW" HeaderText="Last Review" ReadOnly="True" SortExpression="LATEST_REVIEW" DataFormatString="{0:d}" />
                            <asp:BoundField DataField="AptStartTime" HeaderText="Next Review" SortExpression="AptStartTime" DataFormatString="{0:d}" />
                            <asp:BoundField DataField="NextAptWith" HeaderText="NextAptWith" ReadOnly="True" SortExpression="NextAptWith" Visible="False" />
                            <asp:BoundField DataField="NUM_REVIEWS" HeaderText="Num Reviews" ReadOnly="True" SortExpression="NUM_REVIEWS" />
                            <asp:BoundField DataField="MonthOnPOT" HeaderText="MonthOnPOT" ReadOnly="True" SortExpression="MonthOnPOT" />
                            <asp:BoundField DataField="MonthsOnProgramme" HeaderText="Months on Program" ReadOnly="True" SortExpression="MonthsOnProgramme" />
                            <asp:BoundField DataField="EARLIEST_START_DATE" HeaderText="EARLIEST_START_DATE" ReadOnly="True" SortExpression="EARLIEST_START_DATE" DataFormatString="{0:d}" Visible="False" />
                            <asp:BoundField DataField="POTSTATUS" HeaderText="POTSTATUS" SortExpression="POTSTATUS" />
                            <asp:BoundField DataField="PROGRESS_RAG" HeaderText="PROGRESS_RAG" ReadOnly="True" SortExpression="PROGRESS_RAG" />
                            <asp:BoundField DataField="CURRENT_PDM" HeaderText="CURRENT_PDM" SortExpression="CURRENT_PDM" />
                            <asp:BoundField DataField="CONTRACT" HeaderText="CONTRACT" SortExpression="CONTRACT" Visible="False" />
                            <asp:BoundField DataField="TRAINEEID" HeaderText="TRAINEEID" ReadOnly="True" SortExpression="TRAINEEID" Visible="False" />
                            <asp:BoundField DataField="POT" HeaderText="POT" ReadOnly="True" SortExpression="POT" Visible="False" />
                            <asp:BoundField DataField="POTSTATUSID" HeaderText="POTSTATUSID" SortExpression="POTSTATUSID" Visible="False" />
                            <asp:TemplateField HeaderText="Discussed">
                                <EditItemTemplate>
                                    <asp:CheckBox ID="CheckBox1" runat="server" />
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox ID="CheckBox1" runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <EmptyDataTemplate>
                            <asp:CheckBox ID="CheckBox1" runat="server" />
                        </EmptyDataTemplate>
                        <RowStyle BorderStyle="Dashed" BorderWidth="1px" HorizontalAlign="Center" VerticalAlign="Middle" />
                    </asp:GridView>

Open in new window

0
Comment
Question by:edjones1
  • 2
2 Comments
 

Accepted Solution

by:
edjones1 earned 0 total points
ID: 41737375
Solved myself

Add this to the stylesheet

.hidden {
  display: none !important;
  visibility: hidden !important;
}

Open in new window



And set the css of the header at item in the gridview.

HeaderStyle-CssClass = "hidden" ItemStyle-CssClass="hidden"

Open in new window

0
 

Author Closing Comment

by:edjones1
ID: 41737376
Solved with CSS
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now