当前位置: 首页>>代码示例>>C#>>正文


C# GridViewDeletedEventArgs.SetValues方法代码示例

本文整理汇总了C#中System.Web.UI.WebControls.GridViewDeletedEventArgs.SetValues方法的典型用法代码示例。如果您正苦于以下问题:C# GridViewDeletedEventArgs.SetValues方法的具体用法?C# GridViewDeletedEventArgs.SetValues怎么用?C# GridViewDeletedEventArgs.SetValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.WebControls.GridViewDeletedEventArgs的用法示例。


在下文中一共展示了GridViewDeletedEventArgs.SetValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleDeleteCallback

        private bool HandleDeleteCallback(int affectedRows, Exception ex) {
            GridViewDeletedEventArgs sea = new GridViewDeletedEventArgs(affectedRows, ex);
            sea.SetKeys(_deleteKeys);
            sea.SetValues(_deleteValues);

            OnRowDeleted(sea);
            _deleteKeys = null;
            _deleteValues = null;

            if (ex != null && !sea.ExceptionHandled) {
                // If there is no validator in the validation group that could make sense
                // of the error, return false to proceed with standard exception handling.
                // But if there is one, we want to let it display its error instead of throwing.
                if (PageIsValidAfterModelException()) {
                    return false;
                }
            }
            EditIndex = -1;

            if (affectedRows > 0) {
                // Patch up the current page.  We might have deleted the last records on the last page, so move
                // to the right page.
                int rowCount = (int)ViewState[ItemCountViewStateKey];
                // Can't have negative rowCount
                int expectedRowCount = Math.Max(0, rowCount - affectedRows);

                if (AllowPaging) {
                    // Calculate the expected page count
                    int expectedPageCount = 0;
                    checked {
                        // Correctly calculate the expectedPageCount. Special case: We want there to always be at least one page even if there are no items
                        // so that we can always *safely* calculate the pageindex as expectedRowCount - 1
                        expectedPageCount = Math.Max(1, (expectedRowCount + PageSize - 1) / PageSize);
                    }

                    // Adjust the pageIndex based on the expected page count
                    _pageIndex = Math.Min(_pageIndex, expectedPageCount - 1);
                    Debug.Assert(_pageIndex >= 0, "Page index should never be negative!");
                }

                if (SelectedIndex >= 0) {
                    if (expectedRowCount == 0) {
                        // There is nothing to select
                        SelectedIndex = -1;
                    }
                    else {
                        // Calculate the selected index in terms of the row number in the total rows
                        int selectedRow = AllowPaging ? (PageIndex * PageSize) + SelectedIndex : SelectedIndex;
                        // If the selected index is no longer valid make it the last index
                        if (selectedRow > expectedRowCount) {
                            int lastIndex = AllowPaging ? expectedRowCount % PageSize : expectedRowCount;
                            SelectedIndex = lastIndex;
                        }
                    }
                }
            }
            _deletedRowIndex = -1;

            RequiresDataBinding = true;
            return true;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:61,代码来源:GridView.cs

示例2: HandleDeleteCallback

 private bool HandleDeleteCallback(int affectedRows, Exception ex)
 {
     GridViewDeletedEventArgs e = new GridViewDeletedEventArgs(affectedRows, ex);
     e.SetKeys(this._deleteKeys);
     e.SetValues(this._deleteValues);
     this.OnRowDeleted(e);
     this._deleteKeys = null;
     this._deleteValues = null;
     if (((ex != null) && !e.ExceptionHandled) && this.PageIsValidAfterModelException())
     {
         return false;
     }
     this.EditIndex = -1;
     if (affectedRows > 0)
     {
         int num = (int) this.ViewState["_!ItemCount"];
         int num2 = Math.Max(0, num - affectedRows);
         if (this.AllowPaging)
         {
             int num3 = 0;
             num3 = Math.Max(1, ((num2 + this.PageSize) - 1) / this.PageSize);
             this._pageIndex = Math.Min(this._pageIndex, num3 - 1);
         }
         if (this.SelectedIndex >= 0)
         {
             if (num2 == 0)
             {
                 this.SelectedIndex = -1;
             }
             else
             {
                 int num4 = this.AllowPaging ? ((this.PageIndex * this.PageSize) + this.SelectedIndex) : this.SelectedIndex;
                 if (num4 > num2)
                 {
                     int num5 = this.AllowPaging ? (num2 % this.PageSize) : num2;
                     this.SelectedIndex = num5;
                 }
             }
         }
     }
     this._deletedRowIndex = -1;
     base.RequiresDataBinding = true;
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:44,代码来源:GridView.cs


注:本文中的System.Web.UI.WebControls.GridViewDeletedEventArgs.SetValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。