Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Vertical alignment of checkbox in gridview

Vertical alignment of checkbox in gridview

Vertical alignment of checkbox in gridview

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:

vertical-align: middle;

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

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

I've attached a screenshot of what I get.

Thanks in advance,

Jerry Scannell

RE: Vertical alignment of checkbox in gridview

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close