• DataGrid的小技巧之toopTip


    经过一个月来的学习,我总结了用过的几个有关于DataGrid的小技巧:

    1.       为每列绑定相应的ToolTip,让其显示相关的信息。(如图)

    实现代码:

                                                                 private void O_dataGrid_ItemDataBound(object sender,

                               System.Web.UI.WebControls.DataGridItemEventArgs e)

           {

                  if(e.Item.ItemType == ListItemType.AlternatingItem ||

                                e.Item.ItemType == ListItemType.Item)

                  {

                         WebControl V_wc = (WebControl)e.Item.Cells[1].Controls[0];

                         V_wc.ToolTip = "库存量为 "+e.Item.Cells[4].Text+" 个单位";

                  }

           }

    2.鼠标移动到某一行动态显示不同的颜色。(如上图)

    private void O_dataGrid_ItemDataBound(object sender,

    System.Web.UI.WebControls.DataGridItemEventArgs e)

           {

                  if(e.Item.ItemType == ListItemType.AlternatingItem ||

                                e.Item.ItemType == ListItemType.Item)

                  {

                   e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='#FFC66C'");

                   e.Item.Attributes.Add("onmouseout","this.style.backgroundColor='#FFFFFF'");

                         }

           }

    3. 如果DataGrid的项是用样式来确定显示颜色的,代码为:

    private void O_dataGrid_ItemDataBound(object sender,

    System.Web.UI.WebControls.DataGridItemEventArgs e)

           {

                  if(e.Item.ItemType == ListItemType.AlternatingItem ||

                                e.Item.ItemType == ListItemType.Item)

                  {

                                                      e.Item.Attributes.Add("onmouseover",
                                                                  "javascript:this.oldClassName=this.className;this.className='Over'");

                                                      e.Item.Attributes.Add("onmouseout",
                                                                 "javascript:this.className=this.oldClassName");

                   }

           }

  • 相关阅读:
    部署 AppGlobalResources 到 SharePoint 2010
    还原一个已删除的网站集
    使用仪表板设计器配置级联筛选器 (SharePoint Server 2010 SP1)
    File or arguments not valid for site template
    Pex and Moles Documentation
    Content Query Webpart匿名访问
    Running Moles using NUnit Console from Visual Studio
    Calling a WCF Service using jQuery in SharePoint the correct way
    Updating Content Types and Site Columns That Were Deployed as a Feature
    asp.net中判断传过来的字符串不为空的代码
  • 原文地址:https://www.cnblogs.com/aipeli/p/260055.html
Copyright © 2020-2023  润新知