Incorrect CSS style being applied when using ShowHeader="False" with the DetailsViewAdapter

Jan 3, 2008 at 11:20 PM
Edited Jan 3, 2008 at 11:22 PM
I noticed this issue has been resolved with the DataListAdapter, but I just ran into a scenario where I wanted the header field for a DetailsViewRow hidden. What occurs is that the header field is in fact hidden, however, the data for what should be the value portion of the row is incorrectly being applied as the AspNet-DetailsView-Name CSS style. This can be easily reproduced using the sample website project that comes with the CssFriendlyControlAdapters project, by setting (for example) the LastName row ShowHeader property to false, and then viewing the source for the page. You will see that the value is applied to the AspNet-DetailsView-Name style instead of the AspNet-DetailsView-Value style. I editted the source code and found that if you alter the following code it will perform as intended with the ShowHeader property in use:

if (iCell == 0 && ControlAsDetailsView.Fields[iRow].ShowHeader)
{
     writer.WriteAttribute("class", "AspNet-DetailsView-Name");
}
else if (iCell == 1 || (iCell == 0 && !ControlAsDetailsView.Fields[iRow].ShowHeader))
{
     writer.WriteAttribute("class", "AspNet-DetailsView-Value");
}