GridView 简单扩展

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Fanfajin.MyWebControls
{
    /// <summary>
    
/// 增强的 GridView 控件 扩展 
    
/// </summary>

    [DefaultProperty("SelectedValue")]
    [ToolboxData("<{0}:MyGridView runat=server></{0}:MyGridView>")]
    public sealed class MyGridView : System.Web.UI.WebControls.GridView
    {
        #region 公开属性成员
        /// <summary>
        
/// 鼠标经过时颜色
        
/// </summary>      

        [Category("扩展设置")]
        [Description("鼠标经过时颜色")]
        public string MouseOverColor
        {
            get
            {
                if (ViewState["MouseOverColor"] == null)
                {
                    ViewState["MouseOverColor"] = "#9900FF";
                }

                return (string)ViewState["MouseOverColor"];
            }


            set
            {
                ViewState["MouseOverColor"] = value;
            }

        }


        /// <summary>
        
/// 鼠标经过时颜色
        
/// </summary>      

        [Category("扩展设置")]
        [Description("鼠标离开时颜色")]
        public string MouseOutColor
        {
            get
            {
                if (ViewState["MouseOutColor"] == null)
                {
                    ViewState["MouseOutColor"] = "#FFFFFF";
                }

                return (string)ViewState["MouseOutColor"];
            }


            set
            {
                ViewState["MouseOutColor"] = value;
            }

        }


        /// <summary>
        
/// 是否启用 HighlightColor
        
/// </summary>

        [Category("扩展设置")]
        [Description("是否启用 MouseOverColor")]
        public bool IsOpenMouseOverColor
        {
            get
            {
                if (ViewState["enableSelection"] == null)
                {
                    ViewState["enableSelection"] = true;
                }

                return (bool)ViewState["enableSelection"];
            }


            set
            {
                ViewState["enableSelection"] = value;
            }

        }


        /// <summary>
        
/// 是否启用扩展
        
/// </summary>

        [Category("扩展设置")]
        [Description("是否启用扩展")]
        public bool ActivePagerBar
        {
            get
            {
                if (ViewState["enableLNSeaPager"] == null)
                {
                    ViewState["enableLNSeaPager"] = true;
                }

                return (bool)ViewState["enableLNSeaPager"];
            }


            set
            {
                this.AllowPaging = value;
                ViewState["enableLNSeaPager"] = value;
            }

        }


        /// <summary>
        
/// 默认排序(图标显示升序降序时用)
        
/// </summary>

        [Category("扩展设置")]
        [Description("默认排序(图标显示升序降序时用)")]
        public SortDirection SortDirectionAlt
        {
            get
            {
                if (ViewState["sortDirection"] == null)
                {
                    ViewState["sortDirection"] = SortDirection.Ascending;
                }

                return (SortDirection)ViewState["sortDirection"];
            }


            set
            {
                ViewState["sortDirection"] = value;
            }

        }


        /// <summary>
        
/// 默认排序字段(图标显示升序降序时用)
        
/// </summary>

        [Category("扩展设置")]
        [Description("默认排序字段(图标显示升序降序时用)")]
        public string SortExpressionAlt
        {
            get
            {
                if (ViewState["sortExpressionAlt"] == null)
                {
                    ViewState["sortExpressionAlt"] = "";
                }

                return (string)ViewState["sortExpressionAlt"];
            }


            set
            {
                ViewState["sortExpressionAlt"] = value;
            }

        }


        /// <summary>
        
/// Get or Set Image location to be used to display Ascending Sort order.
        
/// </summary>

        [
        Description("降序时显示的图片URL"),
        Category("扩展设置"),
        Editor("System.Web.UI.Design.UrlEditor", typeof(System.Drawing.Design.UITypeEditor)),
        DefaultValue(""),
        ]
        public string SortDescImageUrl
        {
            get
            {
                object o = ViewState["SortImageDesc"];
                return (o != null ? o.ToString() : "");
            }

            set
            {
                ViewState["SortImageDesc"] = value;
            }

        }


        /// <summary>
        
/// Get or Set Image location to be used to display Ascending Sort order.
        
/// </summary>

        [
        Description("升序时显示的图片"),
        Category("扩展设置"),
        Editor("System.Web.UI.Design.UrlEditor", typeof(System.Drawing.Design.UITypeEditor)),
        DefaultValue(""),
        ]
        public string SortAscImageUrl
        {
            get
            {
                object o = ViewState["SortImageAsc"];
                return (o != null ? o.ToString() : "");
            }

            set
            {
                ViewState["SortImageAsc"] = value;
            }

        }



        /// <summary>
        
/// 是否显示升序降序图标
        
/// </summary>

        [
        Description("是否显示升序降序图片URL"),
        Category("扩展设置"),
        Editor("System.Web.UI.Design.UrlEditor", typeof(System.Drawing.Design.UITypeEditor)),
        DefaultValue("false"),
        ]
        public bool IsShowSortDirectionImg
        {
            get
            {
                object o = ViewState["ShowSortDirection"];
                return (o != null ? Convert.ToBoolean(o) : false);
            }

            set
            {
                ViewState["ShowSortDirection"] = value;
            }

        }


        /// <summary>
        
/// 分页信息当前第{0}页共{1}页{2}条记录
        
/// </summary>

        [Category("扩展设置")]
        [Description("分页信息当前第{0}页共{1}页{2}条记录")]
        public string PageInfo
        {
            get
            {
                if (ViewState["PageInfo"] == null)
                {
                    ViewState["PageInfo"] = "当前{0},共{1}页{2}条记录";
                }

                return (string)ViewState["PageInfo"];
            }


            set
            {
                ViewState["PageInfo"] = value;
            }

        }


        /// <summary>
        
/// 当前页左右的数字个数(不包括智能的)
        
/// </summary>

        [Category("扩展设置")]
        [Description("当前页左右的数字个数(不包括智能的)")]
        public int NumCount
        {
            get
            {
                if (ViewState["NumCount"] == null)
                {
                    ViewState["NumCount"] = 5;
                }

                return (int)ViewState["NumCount"];
            }


            set
            {
                ViewState["NumCount"] = value;
            }

        }


        /// <summary>
        
/// 是否显示智能数字
        
/// </summary>

        [Category("扩展设置")]
        [Description("是否显示智能数字")]
        public bool IsShowSmartPage
        {
            get
            {
                if (ViewState["IsShowSmartPage"] == null)
                {
                    ViewState["IsShowSmartPage"] = true;
                }

                return (bool)ViewState["IsShowSmartPage"];
            }


            set
            {
                ViewState["IsShowSmartPage"] = value;
            }

        }


        /// <summary>
        
/// 分页信息显示在左边还是在右边
        
/// </summary>

        [Category("扩展设置")]
        [Description("是否启用 HighlightColor")]
        public bool PageInfoShowLeft
        {
            get
            {
                if (ViewState["PageInfoShowLeft"] == null)
                {
                    ViewState["PageInfoShowLeft"] = true;
                }

                return (bool)ViewState["PageInfoShowLeft"];
            }


            set
            {
                ViewState["PageInfoShowLeft"] = value;
            }

        }


        /// <summary>
        
/// 智能导航数字的第一个的倍数
        
/// </summary>

        [Category("扩展设置")]
        [Description("智能导航数字的第一个的倍数")]
        public int BeiShu
        {
            get
            {
                if (ViewState["BeiShu"] == null)
                {
                    ViewState["BeiShu"] = 10;
                }

                return (int)ViewState["BeiShu"];
            }


            set
            {
                ViewState["BeiShu"] = value;
            }

        }


        /// <summary>
        
/// 当前页的颜色
        
/// </summary>      

        [Category("扩展设置")]
        [Description("当前页的颜色")]
        public string CurrentPageColor
        {
            get
            {
                if (ViewState["CurrentPageColor"] == null)
                {
                    ViewState["CurrentPageColor"] = "red";
                }

                return (string)ViewState["CurrentPageColor"];
            }


            set
            {
                ViewState["CurrentPageColor"] = value;
            }

        }


        /// <summary>
        
/// 智能数字的颜色
        
/// </summary>      

        [Category("扩展设置")]
        [Description("智能数字的颜色")]
        public string SmartPageColor
        {
            get
            {
                if (ViewState["SmartPageColor"] == null)
                {
                    ViewState["SmartPageColor"] = "#00FF00";
                }

                return (string)ViewState["SmartPageColor"];
            }


            set
            {
                ViewState["SmartPageColor"] = value;
            }

        }


        #endregion


        /// <summary>
        
/// When using GridView in certain ways the SortDirection and SortExpression
        
/// properties are sometimes left blank or never changed. When using this control,
        
/// the Alt properties remedy this situation.
        
/// </summary>
        
/// <param name="e"></param>

        protected override void OnSorting(GridViewSortEventArgs e)
        {
            //Handle setting up of sorting info 
            if (!String.IsNullOrEmpty(this.SortExpression))
            {
                SortExpressionAlt = e.SortExpression;
                SortDirectionAlt = e.SortDirection;
            }

            else
            {
                if (SortExpressionAlt == e.SortExpression)
                {
                    if (SortDirectionAlt == SortDirection.Ascending)
                    {
                        SortDirectionAlt = SortDirection.Descending;
                    }

                    else
                    {
                        SortDirectionAlt = SortDirection.Ascending;
                    }

                }

                else
                {
                    SortDirectionAlt = SortDirection.Ascending;
                }


                this.SortExpressionAlt = e.SortExpression;
            }


            base.OnSorting(e);
        }




        #region 初始化在分页功能启用时显示的页导航行。
        /// <summary>
        
/// 初始化在分页功能启用时显示的页导航行。
        
/// </summary>
        
/// <param name="row">一个 GridViewRow,表示要初始化的页导航行。 </param>
        
/// <param name="columnSpan">页导航行应跨越的列数</param>
        
/// <param name="pagedDataSource">一个 PagedDataSource,表示数据源。 </param>

        protected override void InitializePager(GridViewRow row, int columnSpan, PagedDataSource pagedDataSource)
        {
            string pageinfo = this.PageInfo.Replace("{0}", (pagedDataSource.CurrentPageIndex + 1).ToString()).Replace
                ("{1}", pagedDataSource.PageCount.ToString()).Replace("{2}", pagedDataSource.DataSourceCount.ToString());

            if (this.ActivePagerBar)
            {
                base.PagerTemplate = new ExtendGridViewPagerTemplate(
                    this.PageIndex,
                    this.PageCount,
                    this.PagerSettings.FirstPageText,
                    this.PagerSettings.PreviousPageText,
                    this.PagerSettings.NextPageText,
                    this.PagerSettings.LastPageText,
                    pageinfo,
                    this.NumCount,
                    this.IsShowSmartPage,
                    this.BeiShu,
                    this.PageInfoShowLeft,
                    this.SmartPageColor,
                    this.CurrentPageColor
                    );
            }

            base.InitializePager(row, columnSpan, pagedDataSource);
        }

        #endregion


        /// <summary>
        
/// 呈现 GridView 控件之前,必须先为该控件中的每一行创建一个 GridViewRow 对象。
        
/// 在创建 GridView 控件中的每一行时,将引发 RowCreated 事件。这使您可以提供一个这样的事件处理方法,
        
/// 即每次发生此事件时都执行一个自定义例程(如在行中添加自定义内容)。
        
/// </summary>
        
/// <param name="e"></param>

        protected override void OnRowCreated(GridViewRowEventArgs e)
        {
            //给继承者的说明 在派生类中重写 OnRowCreated 时,一定要调用基类的 OnRowCreated 方法,以便已注册的委托对事件进行接收。
            base.OnRowCreated(e);
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //If row selection is enabled then add mouse over scripts to enable on client.
                if (IsOpenMouseOverColor)
                {
                    e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor = '" + this.MouseOverColor + "';");
                    e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor = '" + this.MouseOutColor + "';");
                }

            }

            else if (e.Row.RowType == DataControlRowType.Header && IsShowSortDirectionImg)
            {
                foreach (TableCell headerCell in e.Row.Cells)
                {
                    if (headerCell.HasControls())
                    {
                        AddSortImageToHeaderCell(headerCell);
                    }

                }

            }

        }

        //Header中加入排序的图片
        private void AddSortImageToHeaderCell(TableCell headerCell)
        {
            // 查出headerCell中的 linkButton
            LinkButton lnk = (LinkButton)headerCell.Controls[0];
            if (lnk != null)
            {
                System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
                // 设置图片的URL
                img.ImageUrl = (this.SortDirectionAlt == SortDirection.Ascending ? this.SortAscImageUrl : this.SortDescImageUrl);
                // 如果用户选择了排序,则加入排序图片
                if (this.SortExpressionAlt == lnk.CommandArgument)
                {
                    //加入一个空格
                    headerCell.Controls.Add(new LiteralControl(" "));
                    headerCell.Controls.Add(img);
                }

            }

        }

    }




    /// <summary>
    
/// 分页导航条扩展
    
/// </summary>

    class ExtendGridViewPagerTemplate : ITemplate
    {
        #region 私有成员
        int _pageIndex;//当前页    
        int _pageNumber
        {
            get
            {
                return _pageIndex + 1;
            }

            set
            {
                _pageIndex = value - 1;
            }

        }
//当前页 第一页为 1
        int _pageCount;//总页数
        string _First;
        string _Prev;
        string _Next;
        string _Last;
        string _PageInfo;
        int _NumCount;
        int _Beishu = 3;

        int _StartPage;
        int _EndPage;
        int _MoreStartPage1;
        int _MoreStartPage2;
        int _MoreStartPage3;
        int _MoreEndPage1;
        int _MoreEndPage2;
        int _MoreEndPage3;
        bool _IsShowSmartPage = true;
        bool _PageInfoShowLeft = true;
        string _CurrentPageColor = "red";
        string _SmartPageColor = "#00FF00";
        #endregion


        构造函数

        /// <summary>
        
/// 对象初始化时调用 
        
/// </summary>
        
/// <param name="container"></param>

        public void InstantiateIn(Control container)
        {
            if (_PageInfoShowLeft)
            {
                createPageInfo(container);
                createSpacer(container);
            }


            createFirstLinkButtion(container);//首页
            createSpacer(container);//空格
            createPrevLinkButton(container);//上页
            createSpacer(container);
            numericBar(container);//数字导航条
            createSpacer(container);
            createNextLinkButton(container);//下页
            createSpacer(container);
            createLastLinkButtion(container);//尾页

            if (!_PageInfoShowLeft)
            {
                createPageInfo(container);
                createSpacer(container);
            }


        }

        //成生空格
        private void createSpacer(Control container)
        {
            Literal spacer = new Literal();
            spacer = new Literal();
            spacer.Text = "&nbsp;";
            container.Controls.Add(spacer);
        }

        //生成首页按钮
        private void createFirstLinkButtion(Control container)
        {
            if (_pageIndex > 0)
            {
                LinkButton pageButton;
                pageButton = new LinkButton();
                pageButton.Text = _First;
                pageButton.CommandName = "Page";
                pageButton.CommandArgument = "1";
                container.Controls.Add(pageButton);
            }

            else
            {
                Literal temp = new Literal();
                temp.Text = "<span disabled=true>" + _First + "</span>";
                container.Controls.Add(temp);
            }

        }

        //生成上一页按钮
        private void createPrevLinkButton(Control container)
        {
            if (_pageIndex > 0)
            {
                LinkButton prevButton = new LinkButton();
                prevButton.CommandName = "Page";
                prevButton.CommandArgument = "Prev";
                prevButton.Text = _Prev;
                container.Controls.Add(prevButton);
            }

            else
            {
                Literal temp = new Literal();
                temp.Text = "<span disabled=true>" + _Prev + "</span>";
                container.Controls.Add(temp);
            }

        }

        //生成下一页按钮
        private void createNextLinkButton(Control container)
        {
            if (_pageIndex < _pageCount - 1 && _pageIndex >= 0)
            {
                LinkButton prevButton = new LinkButton();
                prevButton.CommandName = "Page";
                prevButton.CommandArgument = "Next";
                prevButton.Text = _Next;
                container.Controls.Add(prevButton);
            }

            else
            {
                Literal temp = new Literal();
                temp.Text = "<span disabled=true>" + _Next + "</span>";
                container.Controls.Add(temp);
            }

        }

        //生成尾按钮
        private void createLastLinkButtion(Control container)
        {
            if (_pageIndex < _pageCount - 1 && _pageIndex >= 0)
            {
                LinkButton pageButton;
                pageButton = new LinkButton();
                pageButton.Text = _Last;
                pageButton.CommandName = "Page";
                pageButton.CommandArgument = _pageCount.ToString();
                container.Controls.Add(pageButton);
            }

            else
            {
                Literal temp = new Literal();
                temp.Text = "<span disabled=true>" + _Last + "</span>";
                container.Controls.Add(temp);
            }


        }

        //生成数字按钮
        private void createNumericPageButton(Control container, int pageIndex, bool isSmatrPage)
        {

            string _text = (pageIndex + 1).ToString();
            if (isSmatrPage)
            {
                _text = "<font color=\"" + this._SmartPageColor + "\">" + _text + "</font>";
            }

            if (pageIndex == _pageIndex)
            {
                _text = "<font color=\"" + this._CurrentPageColor + "\"><b>" + _text + "</b></font>";
            }

            LinkButton pageButton;
            pageButton = new LinkButton();
            pageButton.Text = _text;
            pageButton.CommandName = "Page";
            pageButton.CommandArgument = (pageIndex + 1).ToString();
            container.Controls.Add(pageButton);
        }


        private void numericBar(Control container)
        {

            #region 跟据 _NumCount 计算出导航条的 起始位置与结束位置
            //如果总页数 小于或等于 导航条的数字个数,则把所有页码显示出来
            if (_pageCount <= _NumCount * 2 + 1)
            {
                _StartPage = 1;
                _EndPage = _pageCount;
            }

            else
            {
                if (_pageNumber <= _NumCount + 1)
                {
                    _StartPage = 1;
                    _EndPage = _NumCount * 2 + 1;
                }

                else
                {
                    if (_pageCount <= _pageNumber + _NumCount)
                    {
                        //显示最后 x*2+1页
                        _StartPage = _pageCount - _NumCount * 2;
                        _EndPage = _pageCount;
                    }

                    else
                    {
                        //正常显示
                        _StartPage = _pageNumber - _NumCount;
                        _EndPage = _pageNumber + _NumCount;
                    }

                }

            }

            #endregion


            #region 输出前N页
            if (_IsShowSmartPage)
            {

                _MoreStartPage1 = _StartPage - _Beishu - 1;
                _MoreStartPage2 = _StartPage - _Beishu * 10 - _Beishu - 1;
                _MoreStartPage3 = _StartPage - _Beishu * 100 - _Beishu * 10 - _Beishu - 1;
                if (_MoreStartPage1 > 0)
                {
                    if (_MoreStartPage3 > 0)
                    {
                        createNumericPageButton(container, _MoreStartPage3, true);
                        createSpacer(container);
                    }

                    if (_MoreStartPage2 > _NumCount * 4)
                    {
                        createNumericPageButton(container, _MoreStartPage2, true);
                        createSpacer(container);
                    }

                    else
                    {
                        if (_MoreStartPage2 > 0)
                        {
                            createNumericPageButton(container, _MoreStartPage2, true);
                            createSpacer(container);
                        }

                    }

                    createNumericPageButton(container, _MoreStartPage1, true);
                    createSpacer(container);
                }


            }

            #endregion


            #region 输出正常数字
            for (int i = _StartPage - 1; i < _EndPage; i++)
            {
                createNumericPageButton(container, i, false);
                createSpacer(container);
            }

            #endregion


            #region 输出后N页
            _MoreEndPage1 = _EndPage + _Beishu - 1;
            _MoreEndPage2 = _EndPage + _Beishu * 10 + _Beishu - 1;
            _MoreEndPage3 = _EndPage + _Beishu * 100 + _Beishu * 10 + _Beishu - 1;
            if (_MoreEndPage1 < _pageCount)
            {
                createNumericPageButton(container, _MoreEndPage1, true);
                createSpacer(container);
                if (_MoreEndPage2 < _pageCount - _NumCount * 4)
                {
                    createNumericPageButton(container, _MoreEndPage2, true);
                    createSpacer(container);
                    if (_MoreEndPage3 < _pageCount)
                    {
                        createNumericPageButton(container, _MoreEndPage3, true);
                        createSpacer(container);
                    }

                }

                else
                {
                    if (_MoreEndPage2 < _pageCount)
                    {
                        createNumericPageButton(container, _MoreEndPage1, true);
                        createSpacer(container);
                    }

                }


            }

            #endregion

        }


        private void createPageInfo(Control container)
        {
            Literal pageinfo = new Literal();
            pageinfo = new Literal();
            pageinfo.Text = _PageInfo;
            container.Controls.Add(pageinfo);
        }

    }


}



 

public partial  class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (ViewState["SelectCmd"] != null)
        {
            SqlDataSource1.SelectCommand = (string)ViewState["SelectCmd"];
            MyGridView1.DataBind();
        }

        
    }


    protected void Button1_Click(object sender, EventArgs e)
    {
        ViewState["SelectCmd"] = "SELECT [tid], [fid], [iconid], [typeid] FROM [Forum_123_topics] where tid>10";
        SqlDataSource1.SelectCommand = (string)ViewState["SelectCmd"];
        MyGridView1.DataBind();
        Response.Write(SqlDataSource1.SelectCommand);
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        ViewState["SelectCmd"] = "SELECT [tid], [fid], [iconid], [typeid] FROM [Forum_123_topics]";
        SqlDataSource1.SelectCommand = (string)ViewState["SelectCmd"];
        MyGridView1.DataBind();
        Response.Write(SqlDataSource1.SelectCommand);
    }

}
分类:  2..NET新手区
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
控件使用<br>1、鼠标经过行的时候改变该行的样式,鼠标离开行的时候恢复该行的样式<br>使用方法(设置属性): <br>MouseOverCssClass - 鼠标经过行时行的 CSS 类名<br><br>2、对多个字段进行复合排序;升序、降序的排序状态提示<br>使用方法(设置SmartSorting复合属性): <br>AllowSortTip - 是否启用排序提示 <br>AllowMultiSorting - 是否启用复合排序 <br>SortAscImageUrl - 升序提示图片的URL(不设置则使用默认图片) <br>SortDescImageUrl - 降序提示图片的URL(不设置则使用默认图片) <br>SortAscText - 升序提示文本 <br>SortDescText - 降序提示文本<br><br>3、根据按钮的CommandName设置其客户端属性<br>使用方法(设置ClientButtons集合属性): <br>BoundCommandName - 需要绑定的CommandName <br>AttributeKey - 属性的名称 <br>AttributeValue - 属性的值(两个占位符:{0} - CommandArgument;{1} - Text) <br>Position - 属性的值的位置<br><br>4、联动复选框(复选框的全选和取消全选)。选中指定的父复选框,则设置指定的所有子复选框为选中状态;取消选中指定的父复选框,则设置指定的所有子复选框为取消选中状态。如果指定的所有子复选框为均选中状态,则设置指定的父复选框为选中状态;如果指定的所有子复选框至少有一个为取消选中状态,则设置指定的父复选框为取消选中状态<br>使用方法(设置CascadeCheckboxes集合属性): <br>ParentCheckboxID - 模板列中 父复选框ID <br>ChildCheckboxID - 模板列中 子复选框ID <br>YYControls.Helper.SmartGridView中的静态方法 <br>List GetCheckedDataKey(GridView gv, int columnIndex) <br>List GetCheckedDataKey(GridView gv, string checkboxId)<br><br>5、固定指定行、指定列,根据RowType固定行,根据RowState固定行 <br>使用方法(设置FixRowColumn复合属性): <br>FixRowType - 需要固定的行的RowType(用逗号“,”分隔) <br>FixRowState - 需要固定的行的RowState(用逗号“,”分隔) <br>FixRows - 需要固定的行的索引(用逗号“,”分隔) <br>FixColumns - 需要固定的列的索引(用逗号“,”分隔) <br>TableWidth - 表格的宽度 <br>TableHeight - 表格的高度<br><br>6、响应行的单击事件和双击事件,并在服务端处理 <br>使用方法(设置属性): <br>BoundRowClickCommandName - 行的单击事件需要绑定的CommandName <br>BoundRowDoubleClickCommandName - 行的双击事件需要绑定的CommandName<br><br>7、行的指定复选框选中的时候改变该行的样式,行的指定复选框取消选中的时候恢复该行的样式 <br>使用方法(设置CheckedRowCssClass复合属性): <br>CheckBoxID - 模板列中 数据行的复选框ID <br>CssClass - 选中的行的 CSS 类名<br><br>8、导出数据源的数据为Excel、Word或Text(应保证数据源的类型为DataTable或DataSet) <br>使用方法: <br>为SmartGridView添加的方法<br>Export(string fileName)<br>Export(string fileName, ExportFormat exportFormat)<br>Export(string fileName, ExportFormat exportFormat, Encoding encoding)<br>Export(string fileName, int[] columnIndexList, ExportFormat exportFormat, Encoding encoding)<br>Export(string fileName, int[] columnIndexList, string[] headers, ExportFormat exportFormat, Encoding encoding)<br><br>9、给数据行增加右键菜单,响应服务端事件或超级链接 <br>使用方法(设置ContextMenus集合属性): <br>Text - 菜单的文本内容 <br>BoundCommandName - 需要绑定的CommandName <br>NavigateUrl - 链接的URL <br>Target - 链接的目标窗口或框架 <br>SmartGridView的属性ContextMenuCssClass - 右键菜单的级联样式表 CSS 类名(右键菜单的结构div ul li a)<br><br>10、自定义分页样式。显示总记录数、每页记录数、当前页数、总页数、首页、上一页、下一页、末页和分页按钮 <br>使用方法(设置CustomPagerSettings复合属性): <br>PagingMode - 自定义分页的显示模式 <br>TextFormat - 自定义分页的文本显示样式(四个占位符:{0}-每页显示记录数;{1}-总记录数;{2}-当前页数;{3}-总页数)<br><br>11、合并指定列的相邻且内容相同的单元格<br>使用方法(设置属性): <br>MergeCells - 需要合并单元格的列的索引(用逗号“,”分隔)<br>

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值