ASP.NET---自定义GridView控件小结

1、新建一个继承自GridView的类。

2、加一个属性,用来指定鼠标经过行时,行的css类名

3、重写OnRowDataBound实现鼠标经过行时改变行的样式的功能。主要是给<tr>增加onmouseover事件和onmouseout事件。

4、测试
=========ASPX文件=======
<zyz:SmartGridView ID="sgvList" runat="server">
</zyz:SmartGridView>

=======css文件======
.over 
{
    background-color : Red;
}

=====skin文件====
<zyz:SmartGridView runat="server" CssClassMouseOver="over">
</zyz:SmartGridView>

=======Web.Config文件===========
<pages styleSheetTheme="blue">
   <controls>
    <add assembly="MyControl" namespace="MyControl" tagPrefix="zyz"/>
   </controls>
</pages>

参考

原文地址:https://www.cnblogs.com/beast-king/p/3451094.html