Hey,

I found this little pdf on asp.net that discussed how to place separator lines within a GridView. Unfortunately for me it was in VB. So i spent some time translating it and think i have it working.

Here is the pdf

So for anyone who wants something like this but uses C#, here is the translation as far as i can tell. in this example all you need is a GridView called GridView1 and some boundfields and you should be good to go.

Code Csharp:
protected override void Render(HtmlTextWriter writer)
        {
            // Only add the sorting UI if the GridView is sorted 
            if (!string.IsNullOrEmpty(GridView1.SortExpression))
            {
                //  Determine the index and HeaderText of the column that
                // the data is sorted by
                int sortColumnIndex = 1;
                string sortColumnHeaderText = String.Empty;
                for (int i = 0; (i <= GridView1.Columns.Count); i++)
                {
                    if ((GridView1.Columns[i].SortExpression.CompareTo(GridView1.SortExpression) == 0))
                    {
                        sortColumnIndex = i;
                        sortColumnHeaderText = GridView1.Columns[i].HeaderText;
                        break;
                    }
                }
 
 
                // Reference the Table the GridView has been rendered into 
                Table gridTable = (Table)GridView1.Controls[0];
 
                // Enumerate each TableRow, adding a sorting UI header if 
                // the sorted value has changed 
                string lastValue = string.Empty;
 
                foreach (GridViewRow gvr in GridView1.Rows)
                {
                    string currentValue = gvr.Cells[sortColumnIndex].Text;
                    if (lastValue.CompareTo(currentValue) != 0)
                    {
                        // there's been a change in value in the sorted column 
                        int rowIndex = gridTable.Rows.GetRowIndex(gvr);
                        // Add a new sort header row 
                        GridViewRow sortRow = new GridViewRow(rowIndex, rowIndex, DataControlRowType.DataRow, DataControlRowState.Normal);
                        TableCell sortCell = new TableCell();
                        sortCell.ColumnSpan = GridView1.Columns.Count;
                        sortCell.Text = string.Format("{0}: {1}", sortColumnHeaderText, currentValue);
                        sortCell.CssClass = "SortHeaderRowStyle";
                        // Add sortCell to sortRow, and sortRow to gridTable 
                        sortRow.Cells.Add(sortCell);
                        gridTable.Controls.AddAt(rowIndex, sortRow);
                        // Update lastValue 
                        lastValue = currentValue;
                    }
                }
            }
 
            base.Render(writer);
        }

If you have any changes please let me know and i will modify it (I think the translator i used may have added some extra stuff in there that is not needed). So far this has worked quite well for me.

Ras