EbiPenMan
جمعه 18 تیر 1389, 23:11 عصر
سلام به همگی
من با استفاده از تمپلیت در دیتا گرید دکمه حذف ساختم و این کدا رو در قسمت RowCammand گذاشتم.
if (e.CommandName == "Delete")
{
CheckBox chkRemove;
Label DBLC;
string strIDs = "";
foreach (GridViewRow DGItem in GV_AddRem_Admin.Rows)
{
chkRemove = (CheckBox)DGItem.FindControl("chk_Remove");
if (chkRemove.Checked == true)
{
DBLC = (Label)DGItem.FindControl("lbl_AdminName");
strIDs += DBLC.Text + ",";
}
}
string strSQL = "Delete From [tbl_Admins] Where [AdminName] IN ('" + strIDs.Substring(0, strIDs.LastIndexOf(",")) + "')";
SDS_AddRem_Admin.DeleteCommand = strSQL;
SDS_AddRem_Admin.Delete();
}
حالا این کد درست کار میکنه و حذف میکنه ولی بعدش این خطا تو صفحه میاد:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
حالا نمی دونم این کد برای دیتا گرید هست که یه رکورد حدف شده خطا میده یا چيز دیگه ای.
بعد از این کدام چه پراپرتیه دیتاگریدم و باید آپدیت کنم؟
من با استفاده از تمپلیت در دیتا گرید دکمه حذف ساختم و این کدا رو در قسمت RowCammand گذاشتم.
if (e.CommandName == "Delete")
{
CheckBox chkRemove;
Label DBLC;
string strIDs = "";
foreach (GridViewRow DGItem in GV_AddRem_Admin.Rows)
{
chkRemove = (CheckBox)DGItem.FindControl("chk_Remove");
if (chkRemove.Checked == true)
{
DBLC = (Label)DGItem.FindControl("lbl_AdminName");
strIDs += DBLC.Text + ",";
}
}
string strSQL = "Delete From [tbl_Admins] Where [AdminName] IN ('" + strIDs.Substring(0, strIDs.LastIndexOf(",")) + "')";
SDS_AddRem_Admin.DeleteCommand = strSQL;
SDS_AddRem_Admin.Delete();
}
حالا این کد درست کار میکنه و حذف میکنه ولی بعدش این خطا تو صفحه میاد:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
حالا نمی دونم این کد برای دیتا گرید هست که یه رکورد حدف شده خطا میده یا چيز دیگه ای.
بعد از این کدام چه پراپرتیه دیتاگریدم و باید آپدیت کنم؟