CSS分页样式未应用于动态GridView

时间:2019-04-29 12:59:19

标签: c# css asp.net gridview

我知道这个问题已经被问了很多,但是我已经完成了建议的问答,但是找不到任何可以解决我所遇到的问题的东西。

我有一个asp gridview控件,该控件仅被动态调用并构建,之后我尝试应用CSS样式,但又不想接受我的分页样式,将非常感谢您的协助。这是一些代码片段,样式表

.pagination-ys {
    /*display: inline-block;*/
    padding-left: 0;
    margin: 20px 0;
    border-radius: 4px;
}

.pagination-ys table > tbody > tr > td {
    display: inline;
}

.pagination-ys table > tbody > tr > td > a,
.pagination-ys table > tbody > tr > td > span {
    position: relative;
    float: left;
    padding: 8px 12px;
    line-height: 1.42857143;
    text-decoration: none;
    color: #dd4814;
    background-color: #ffffff;
    border: 1px solid #dddddd;
    margin-left: -1px;
}

.pagination-ys table > tbody > tr > td > span {
    position: relative;
    float: left;
    padding: 8px 12px;
    line-height: 1.42857143;
    text-decoration: none;
    margin-left: -1px;
    z-index: 2;
    color: #aea79f;
    background-color: #f5f5f5;
    border-color: #dddddd;
    cursor: default;
}

.pagination-ys table > tbody > tr > td:first-child > a,
.pagination-ys table > tbody > tr > td:first-child > span {
    margin-left: 0;
    border-bottom-left-radius: 4px;
    border-top-left-radius: 4px;
}

.pagination-ys table > tbody > tr > td:last-child > a,
.pagination-ys table > tbody > tr > td:last-child > span {
    border-bottom-right-radius: 4px;
    border-top-right-radius: 4px;
}

.pagination-ys table > tbody > tr > td > a:hover,
.pagination-ys table > tbody > tr > td > span:hover,
.pagination-ys table > tbody > tr > td > a:focus,
.pagination-ys table > tbody > tr > td > span:focus {
    color: #97310e;
    background-color: #eeeeee;
    border-color: #dddddd;
}
/*end gridview */

这是在自定义的Public类中

public string _gridClassStyle = "table table-striped table-bordered table-hover";
public string _gridPagerStyle = "pagination-ys";

public string GridClass
{
    get
    {
        return _gridClassStyle;
    }
}
public string GridPagerClass
{
    get
    {
        return _gridPagerStyle;
    }
}

这是背后的代码

GridView gv = new GridView();
string dynamicGridClass = gc.GridClass.ToString();
string pagerStyle = gc.GridPagerClass.ToString();

gv.DataSource = dt;
gv.DataBind();
gv.PageSize = 10;
gv.AllowPaging = true;
gv.HeaderRow.TableSection = TableRowSection.TableHeader;
gv.Rows[0].Visible = false;
gv.CssClass = dynamicGridClass;
gv.PagerStyle.CssClass = pagerStyle;
phUploadFile.Controls.Add(gv);

0 个答案:

没有答案