Today I had to find a way to force x number of rows on a GridView. The problem is that if the GridView.PageSize is larger than the number of rows you are data binding, the GridView itself gets smaller in the height. You often see it when paging through the pages of a grid. The last page is always shorter than the rest, because there are fewer rows. That is usually not a issue, but I had to keep our designers happy.

It is actually pretty simple in a class that inherits from System.Web.UI.WebControls.GridView. Just override the OnDataBound method and add the extra rows. In this example, the number of rows is always the same as the PageSize property and still keeping the footer row at the bottom.

protected override void OnDataBound(EventArgs e)
{
 GridViewRow gvRow = null;

 for (int rows = this.Rows.Count; rows < this.PageSize; rows++)
 {
  gvRow = new GridViewRow(0, 0, DataControlRowType.DataRow, DataControlRowState.Normal);

  for (int columns = 0; columns < this.Columns.Count; columns++)
  {
   gvRow.Controls.Add(new TableCell());
  }

  //Inserts the rows right above the footer row.
  //Remove the "- 1" if you are not using a footer.
  this.Controls[0].Controls.AddAt(this.Controls[0].Controls.Count - 1, gvRow);
 }
}

I used nDoc all the time back in the days of Visual Studio 2003. nDoc is a tool that creates documentation based upon the XML comment you write in your source code files. Then came VS 2005 and, as far as I understand, nDoc had to be rewritten in order for Generics to work. That was back in the Whidbey beta 1 time frame in late 2004, and is still stuck there.

I have searched the web many, many times, trying to find a substitute to nDoc. I didn't find squat. I haven't been able to create source code documentation in Visual Studio 2005 and I've been using it for about a year now. That's a long time without documentation.

If you know of a code comment documentation tool for VS 2005, please make a comment about it. Your help is much appreciated.