How do you pad an ASP.NET GridView?

Posted on 2009-02-15
Last Modified: 2012-05-06
I have a gridview where I've left the height of each row blank.  The data inserted will determine the height.  I would like to put a little padding between each row so that the images (which are typically the tallest element in each row) don't stack on top each other.  I've attempted to define a number for CellPadding, but it doesn't seem to change anything.  Any hints?
Question by:kmerlo
    LVL 16

    Accepted Solution

    Use a style sheet and add it for each row in the gridview when it binds
    <style type="text/css">
        protected void gvTest_RowDataBound(object sender, GridViewRowEventArgs e)
            e.Row.CssClass = "addpadding";

    Open in new window

    LVL 15

    Assisted Solution

    I would just set it in the rowstyle property of the gridview.

    <style type="text/css">
    .pad { padding-top: 10px; }

    <asp:GridView ID="GridView1" runat="server">
            <RowStyle CssClass="pad" />

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Suggested Solutions

    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now