熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

gridview行顏色漸變

2013-11-13 09:40:43  來源: .NET編程 

  行之間顏色間隔:

  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中實現


From:http://tw.wingwit.com/Article/program/net/201311/11310.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.