zoukankan      html  css  js  c++  java
  • GridView TemplateField 动态添加取消颜色

    在对 Gridview 模板列设置选中行的颜色时,采用 默认的 SelectRowStyle 时,不能在选中一个模板列时,改变它的颜色, 需要采用别的办法才能实现.

         前台代码:

                  ...............

                <asp:TemplateField ShowHeader="False">
                                                          <ItemTemplate>
                                                             <asp:LinkButton ID="linkstoreerName" runat="server" StoreerID='<%#Eval("StoreerID") %>'  Text='<%#Eval("StoreerName")%>' OnClick="linkstoreerName_Click" />
                                                          </ItemTemplate>
                                                      </asp:TemplateField>

                 .................

       后台代码:

               //如果有已经设置了颜色的行,先去掉设置的颜色

                int index = -1;
                if (ViewState["index"] != null)
                {
                    int inex = Int32.Parse(ViewState["index"].ToString());
                    gvwrestaurant.Rows[inex].Attributes.Clear();
                }

                LinkButton linkstoreerName = sender as LinkButton;
                string StoreerID = linkstoreerName.Attributes["StoreerID"].ToString();
                GridViewRow row = (GridViewRow)linkstoreerName.Parent.Parent;
                 index = row.RowIndex;
               //对当前行设置颜色
                row.Attributes.Add("style", "background:#ff6600");
                ViewState["index"] = index;

  • 相关阅读:
    phpquery中文手册
    Fiddler工具使用介绍一
    Xshell出现要继续使用此程序必须应用到最新的更新或使用新版本
    PHP Ajax 跨域问题最佳解决方案
    charles和Fiddler感觉哪个更好用
    趣味小应用:用HTML5消磨时光 狼人:
    开发人员必知的20+HTML5技巧 狼人:
    云计算时代:LAMP何去何从? 狼人:
    Adobe改善Flash隐私功能 狼人:
    LAMP网站架构方案分析 狼人:
  • 原文地址:https://www.cnblogs.com/activities/p/2178974.html
Copyright © 2011-2022 走看看