【问题标题】:Styling ASP.NET Grid View Control设置 ASP.NET 网格视图控件的样式
【发布时间】:2011-08-04 15:42:04
【问题描述】:

我正在使用 Grid View Control 并在后面的代码中将数据表绑定到此,我已将页面大小设置为 5。并将行样式和备用行样式高度设置为 70px。

如果我在网格视图页面中有 5 行,则显示很好。但如果我得到的行数少于 5 行,则行扩展以使用可用的 spce。

我已将 420px 高度设置为网格视图。请帮帮我..

样式表是这样的:

    mGrid
    {

        border-collapse: collapse;
        width: 340px;
        height: 420px;


    }
    .mGrid .emptyrowstyle
    {
        height: 70px; font-size: 11px; padding: 6px 0 0 8px; border-bottom: 2px solid #fff; color:#505050; 
        /*line-height: 12px;*/
        background: url(../townlist_bg.jpg); 

    }
    .mGrid .alt
    {
        font-size: 11px; padding: 6px 0 0 8px; border-bottom: 2px solid #fff; color:#505050; height: 70px; 
        /*line-height: 12px;*/
        background: url(../townlist_bg.jpg); 
       /* background-image: url('../m_images/townlist_bg.jpg');*/
    }
    .mGrid .pgr
    {
        height: 15px;
        background: #424242 url(../m_images/grd_pgr.png) repeat-x top;
    }
    .mGrid .rowstyle
    {
        font-size: 11px;  border-bottom: 2px solid #fff; color:#505050; background-image:url(../townlist_bg.jpg); height: 70px; 
        /*height: 12px;*/
        /*background: #fcfcfc url(grd_alt.png) repeat-x top;*/
        /*background: url(../townlist_bg.jpg); */
    }
    .mGrid .pgr table
    {
        margin: 5px 0;
    }
    .mGrid .pgr td
    {
        border-width: 0px;
        padding: 0 6px;
        border-left: solid 0px #666;
        font-weight: bold;
        color: #fff;
        line-height: 12px;
    }
    .mGrid .pgr a
    {
        color: #666;
        text-decoration: none;
    }
    .mGrid .pgr a:hover
    {
        color: #000;
        text-decoration: none;
    }

这是网格视图声明:为简单起见,我没有粘贴数据绑定列:

CssClass="mGrid" AutoGenerateColumns="False" PageSize="5" OnPageIndexChanging="grdvListings_PageIndexChanging" RowStyle-CssClass="rowstyle" ShowHeader ="false" AlternatingRowStyle-CssClass="alt" PagerStyle-CssClass="pgr">

谢谢

【问题讨论】:

    标签: c# asp.net


    【解决方案1】:

    您需要从表格 (mGrid) 中删除高度样式。

    如果您只希望表格与实际行数指示的一样高,则应让行的高度样式决定表格的高度。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-21
      • 2013-08-04
      • 2012-10-16
      • 2016-12-21
      • 2012-03-02
      • 1970-01-01
      • 1970-01-01
      • 2014-06-28
      相关资源
      最近更新 更多