2018-11-22

鼠标移动换色事件

protected void QMSInfoGDV_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType==DataControlRowType.DataRow)
            {
                //当鼠标停留时更改背景色
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#95B8FF'");
                //当鼠标移开时还原背景色
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
                //设置悬浮鼠标指针形状为"小手"
                e.Row.Attributes["style"] = "Cursor:hand";
                //单击 事件
                //e.Row.Attributes.Add("OnClick", "ClickEvent('" + e.Row.Cells[10].FindControl("btnDetial").ClientID + "')");
            }
        }

分页

/// 
        /// 分页
        /// 
        /// 
        /// 
        /// 
        protected string GridviewPagenation(int PageIndex, int PageSize)
        {
            DataTable ds = new DataTable();
            DataTable QMSTable = CacheDataHelper.GetDataTable(Request.Cookies["ASP.NET_SessionId"].Value, System.IO.Path.GetFileName(Request.Path).ToString() + "QMSTable");

            if (QMSTable == null)
                return "Null";
            ds = QMSTable.Clone();
            int GridAllItem = QMSTable.Rows.Count;//所有行数

            int AllPageNum = GridAllItem / PageSize + (GridAllItem % PageSize > 0 ? 1 : 0);
            if (PageIndex != AllPageNum)
            {
                for (int i = (PageIndex - 1) * PageSize, j = 0; i < (PageIndex - 1) * PageSize + PageSize; i++, j++)
                {
                    ds.Rows.Add(QMSTable.Rows[i].ItemArray);
                }
            }
            else
            {
                for (int i = (PageIndex - 1) * PageSize, j = 0; i < GridAllItem; i++, j++)
                {
                    ds.Rows.Add(QMSTable.Rows[i].ItemArray);
                }
            }
            this.QMSInfoGDV.DataSource = null;
            this.QMSInfoGDV.DataSource = ds;
            this.QMSInfoGDV.DataBind();
            return PagingMethod.RenderGridView(this.QMSInfoGDV);
        }

你可能感兴趣的:(2018-11-22)