MVC3 WebGrid header alignment

2019-08-04 06:29发布

问题:

WebGrid (Razor)

How can the headers alignment be set?

I need to be able to change the alignment for each column (could be different)

It seems to be a all or nothing deal nor does it seem to take the alignment of the child TD.

回答1:

There currently is not a way to set a different style for each column header using the WebGrid in MVC 3. You can however use the tableStyle property to set the style for all column headers.

.header { text-align: left; }

@var grid = new WebGrid(Model);

@grid.GetHtml(headerStyle: "header")