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