Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vertical alignment of checkbox in gridview

Status
Not open for further replies.

JScannell

Programmer
Jan 9, 2001
306
US
I've been all around the internet on this. Every place I go says this should work. But it doesn't! The only way I can get my checkbox to align vertically in the middle is to make the row very high (line-height: 200%;)

So, someone please tell me why this code doesn't work:

css:
.Grid_CheckBox
{
vertical-align: middle;
}

Markup:
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="SelectCheckBox" runat="server" Width="40px" />
</ItemTemplate>
<ItemStyle CssClass="Grid_CheckBox" />
</asp:TemplateField>

Or this markup:
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="SelectCheckBox" runat="server" Width="40px" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:TemplateField>

I've attached a screenshot of what I get.

Thanks in advance,
Jerry

Jerry Scannell
 
 http://files.engineering.com/getfile.aspx?folder=d7b4e885-b958-425d-974a-ef7d209f6f65&file=MisalignedCheckbox.jpg
Have you used any of the developer tools in any of the browsers to inspect your markup and css?
I like to use FireFox with the FireBug plug in. Then, run your page and hit F12. There will will a pane on the bottom where you can do all kinds of things. I find this very helpful to find JS errors and figure out CSS issues.
I would highlight the checkbox in the firebug to see the actual height of the checkbox. There may be a span or div around it that you don't see. If it is as high as the height of your cell, then setting the vertical alignment won't do anything.

First do some investigation in one of the browsers using the built in developer tools. IE has it, Chrome, and as mentioned FireBug for FireFox.

Let me know what you come up with
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top