Hello
I am having issues displaying vertical lines between the columns in my grid view. I have tried few suggestions that I have found online however none of them worked for me. Your help solving this issue would be appreciated. My code is attached below. Thank you.

Emily FosterPosted Mar 7, 2025, 8:17 AM
To add vertical lines between the columns in your ASP.NET GridView, you can make use of CSS styles by defining a style class for the cells in the GridView columns. Here's how you can modify your existing code to achieve the desired effect:
1. Add a CSS class to your GridView columns to specify the border style:
2. Apply the CSS class to the cells in your GridView columns:
By adding the CSS class "gridViewCell" to your GridView cells, you can specify a right border style to create the vertical lines between the columns. This approach overrides the default GridLines setting of the GridView, allowing for more customizable styling.
I hope this solution helps resolve the issue you are facing with displaying vertical lines in your GridView. Let me know if you encounter any further challenges or need additional assistance!
Tuhin PaulPosted Mar 8, 2025, 6:07 AM
Code:
Tuhin PaulPosted Mar 8, 2025, 4:58 AM
The issue with displaying vertical lines between columns in your
GridViewis likely due to the fact that theGridLines="Both"property only applies borders to the cells, but not necessarily to the content within the cells. Certain styles (like those applied toItemStyle) might override or conflict with the grid's default border settings.Ensure
GridLines="Both"is SetYou already have
GridLines="Both", which is correct. This ensures both horizontal and vertical lines are drawn.Explicitly Define Cell Borders
Add
BorderStyle,BorderColor, andBorderWidthto theItemStyleandHeaderStyleof each column to ensure consistent borders for all cells.Update Your Code
Modify your
GridViewcode as follows:Crown ClitPosted Mar 7, 2025, 10:44 AM
Hi Emily
Thank you. That worked.
How would i apply the same css to the column headers?