gridview行删除 [英] gridview row deleting
问题描述
GridView delete命令工作正常,但是当您在单击了delete command链接后立即从浏览器刷新页面时,即删除了下一个项目.在每次刷新单击时,驻留在该索引中的项目将被删除,我尝试重置RowIndex值,但是如您所知,它是ReadOnly属性,不能分配给任何值.任何建议
不在乎我的代码和使用方式,请尝试使用您的代码并手动在gridview中删除一个项目,然后刷新页面,下一个项目将被删除,
看看这篇文章,所有Grid都有相同的问题
在ASP中插入,更新,删除. NET Gridview,SQL Server的数据源,MS Access(mdb/accdb),XML和Framework的2.0/3.0/3.5/4.0(VS 2005/2008/2010) [
The GridView delete command is working fine but when you refresh the page from the browser directly after the delete command link is cliked the next item is deleted .ie. on every refresh click the item residing inside that index is getting deleted,, i tried resetting the RowIndex value but as u know that is ReadOnly property and cant be assigned to any value. any suggesstions
Dont care about my code and the way i am using,, try with your on code and delete an item in gridview manually and refresh the page the next item will get deleted,,
Have a look at this article,, all that Grids Having the same issue
Insert, Update, Delete in ASP.NET Gridview, DataSource as SQL Server, MS Access (mdb/accdb), XML and Framework as 2.0 / 3.0 / 3.5 / 4.0 (VS 2005/2008/2010)[^]
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
SPSite siteCollection = new SPSite(SPContext.Current.Web.Url);
using (SPWeb web = siteCollection.OpenWeb())
{
SPListItemCollection listItems = web.Lists["FinalList"].Items;
int itemCount = listItems.Count;
GridViewRow row = GridView1.Rows[e.RowIndex];
if (e.RowIndex < itemCount)
{
listItems.Delete(e.RowIndex);
Label1.Text = "Done! ";
}
GridView1.Dispose();
web.Close();
web.Dispose();
}
}
推荐答案
作为一个简单的解决方案,请使用
As a simple solution, please redirect on same page on RowDeleted event using
Response.Redirect(Request.URL.ToString())
这篇关于gridview行删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!