If you are writing a report using a .NET DataGrid, it’s very possible that you’ll want to conditionally highlight key data in the report. Continue reading “ASP.NET DataGrid: Conditionally Coloring Cell Background Color for a Column Based on the Cell Contents”
ASP.NET GridView Paging Problem – Paging Increases the First Column Width
A request came to my desk today about a project that is using an ASP.NET 2.0 DataGrid control to display a set of data. The DataGrid has paging enabled, but the client was complaining that the first column of the report was far too wide for the data it was displaying.
I took a look into this and the client definitely had a point. Although the numeric values of the first column were single digit integers, the Paging information that the ASP.NET environment was appending extended the width of the first ID column to over 150 pixels which was far too wide.
The Problem with the DataGrid Control
When I looked into the HTML markup of the DataGrid the reason for the large first column became apparent. The DataGrid was displaying rows of data with 5 table cells per row, but the final paging row being appended to the DataGrid only had a single table cell into which the numeric paging links were being added.
I looked this problem up online and found that many people have run into this bug throughout the past few years. But I assume that no fix for this issue has ever been released since the DataGrid control is now deprecated.
Below is an example of what the last two rows of markup looked like for the DataGrid, with the last (paging) row containing only one table cell.
Continue reading “ASP.NET GridView Paging Problem – Paging Increases the First Column Width”