In my GridView I am using w3schools css. Inside the grid view, I want to hide one column (BoundField) but not by setting the "Visible = false" as I want to access that columns data.
For the BoundField (The column I want to hide) I am using css to hide it by giving "" and the HeaderStyle-cssClass="hidden".
When I apply the w3schools css in the grid view it overrides the css in the BoundField.
If I remove the w3schools css then the BoundField css works fine but I have lost the GridView design.
How can I make both the css work together? If not possible then how can i hide that column without using "Visible = false".
Giving the code below.
In the head section:
<script type="text/css">
.hiddenGV
{
display:none;
}
</script>
In the body section
`<asp:GridView ID="GridView1" runat="server" class="w3-table w3-striped w3-bordered w3-card-4 gridtop" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" AutoGenerateColumns="False" DataKeyNames="Project_ID,Instance_ID" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="Project_ID" HeaderText="Project_ID" ReadOnly="True" SortExpression="Project_ID" HeaderStyle-CssClass="hiddenGV" ><ItemStyle CssClass="hiddenGV"/></asp:BoundField>
`
A couple of thing wrong here. Your css class in the head is incorrect in that it should be in a style tag. In the BoundField you do not need to add an ItemStyle tag because ItemStyle is a property of BoundField. To hide the column and still be able to access the value, use this css in the head
Then in the BoundField set the css for the header and data rows like this: