行之间颜色间隔: gridview<AlternatingRowStyle ForeColor=#ffffff BackColor=#ECECEC /> datalist/datagrid<AlternatingItemStyle ForeColor=#ffffff BackColor=#ECECEC /> 鼠标滑过颜色变化 gridview 代码 protected void GridView_RowDataBound(object sender GridViewRowEventArgs e) { if (eRowRowType == DataControlRowTypeDataRow) { eRowAttributesAdd(onmouseover currentColor=thisstylebackgroundColor;thisstylebackgroundColor=#ED); eRowAttributesAdd(onmouseout thisstylebackgroundColor=currentColor); //单击行改变行背景颜色 eRowAttributesAdd(onclickthisstylebackgroundColor=颜色; lor=buttontext;thisstylecursor=default;); } } datagird: 代码 protected void dgValueInfo_ItemDataBound(object sender DataGridItemEventArgs e) { if (eItemItemIndex != ) { eItemCells[]Text = (eItemItemIndex + )ToString(); ListItemType itemType = eItemItemType; if (itemType == ListItemTypeItem) { eItemAttributesAdd(onmouseover e=thisstylebackgroundColor; thisstylebackgroundColor=#FBFF); eItemAttributesAdd(onmouseout thisstylebackgroundColor=e); } } } datalist: 这个用类似上面的方式好像没有效果所以可以考虑在页面去实现 代码 <asp:DataList ID=dlMain runat=server > <AlternatingItemStyle ForeColor=#ffffff BackColor=#ECECEC /> <HeaderTemplate> <asp:Table ID=tabHeader runat=server CssClass=gridviewHead> <asp:TableRow CssClass=Header> <asp:TableCell CssClass=gridviewHead>序号 </asp:TableCell> </asp:TableRow> </asp:Table> </HeaderTemplate> <ItemTemplate> <asp:Table ID=tabItem runat=server CssClass=GridTableTDCenter> <asp:TableRow onmouseover=currentColor=thisstylebackgroundColor;thisstylebackgroundColor=#FBFF onmouseout=thisstylebackgroundColor=currentColor> <asp:TableCell CssClass=GridTableTDCenter><#ContainerItemIndex+%></asp:TableCell> </asp:TableRow> </asp:Table> </ItemTemplate> </asp:DataList> 或者有table则在tr中实现 |