当我将鼠标悬停在gridview上时,我应用css突出显示鼠标所在的行。这将应用于寻呼机,尽管它位于我的gridview的顶部和底部。我可以不将颜色样式css应用于寻呼机行吗? 谢谢 达莫
CSS
.mGrid tr:hover{background-color:#FFFFCC;color:white;}
HTML
<asp:GridView ID="GridViewMain" OnRowDataBound="RowDataBound" OnPageIndexChanging="GridViewMain_PageIndexChanging"
runat="server" AllowPaging="True" PageSize="5" PagerSettings-Position="TopAndBottom"
CssClass="mGrid"
PagerStyle-CssClass="pgr"
AlternatingRowStyle-CssClass="alt"
OnRowCreated="GridViewMain_RowCreated">
</asp:GridView>
代码背后为寻呼机添加下拉列表
protected void GridViewMain_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Pager)
{
DropDownList GridViewMainddl = new DropDownList();
//adds variants of pager size
GridViewMainddl.Items.Add("5");
GridViewMainddl.Items.Add("10");
GridViewMainddl.Items.Add("20");
GridViewMainddl.Items.Add("50");
GridViewMainddl.Items.Add("100");
GridViewMainddl.Items.Add("200");
GridViewMainddl.Items.Add("500");
GridViewMainddl.Items.Add("All");
GridViewMainddl.AutoPostBack = true;
//selects item due to the GridView current page size
ListItem li = GridViewMainddl.Items.FindByText(GridViewMain.PageSize.ToString());
if (li != null)
GridViewMainddl.SelectedIndex = GridViewMainddl.Items.IndexOf(li);
GridViewMainddl.SelectedIndexChanged += new EventHandler(GridViewMainddl_SelectedIndexChanged);
//adds dropdownlist in the additional cell to the pager table
Table pagerTable = e.Row.Cells[0].Controls[0] as Table;
TableCell cell = new TableCell();
cell.Style["padding-left"] = "15px";
cell.Controls.Add(new LiteralControl("Page Size:"));
cell.Controls.Add(GridViewMainddl);
pagerTable.Rows[0].Cells.Add(cell);
}
}
答案 0 :(得分:2)
使用RowStyle-CssClass
的{{1}}属性将类应用于网格中的数据行。然后在样式表中使用该类来应用悬停样式。
GridView的:
GridView
风格:
<asp:GridView ID="GridViewMain"
OnRowDataBound="RowDataBound"
OnPageIndexChanging="GridViewMain_PageIndexChanging"
runat="server"
AllowPaging="True"
PageSize="5"
PagerSettings-Position="TopAndBottom"
CssClass="mGrid"
PagerStyle-CssClass="pgr"
AlternatingRowStyle-CssClass="alt data-row"
RowStyle-CssClass="data-row"
OnRowCreated="GridViewMain_RowCreated">
</asp:GridView>