PDA

View Full Version : خطا:روبه رو شدن با خطای The GridView 'GridView1' fired event RowDeleting which wasn't ha



ERIKA
دوشنبه 25 مهر 1390, 17:18 عصر
با سلام
من کد زیر را برای حذف مینویسم عملیات حذف انجام میشه ولی به جای نمایش دیتا گرید ویو صفحه با خطای زیر روبه رو میشوم


protectedvoid GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
string ID = GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[0].Text;
cn.Command("delete from tbStudent where StudentID=" + ID);
GridView1.DataSource = null;
cn.bindGrid("select * from tbStudent order by StudentID", GridView1);
lblMessage.Text = "عمليات حذف با موفقيت انجام شد!";
}
if (e.CommandName == "Edit")
{
Session.Contents.Add("StudentID", GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[0].Text);
int ID = Convert.ToInt32(Session.Contents["StudentID"]);
txtStudentNumber.Text = Convert.ToString(GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[1].Text);
txtName.Text = (GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[2].Text);
txtFamily.Text = (GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[3].Text);
txtNational.Text = (GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[4].Text);
txtNational.Text = (GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[5].Text);
txtStudentNumber.Text = (GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[6].Text);
txtAdress.Text= (GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[7].Text);
txtEmail.Text= (GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[8].Text);
txtTarikhTavaold.Text = (GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[9].Text);
txtSex.Text = (GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[10].Text);
btnEdit.Visible = true;
من بریک پوینت هم گذاشتم عملیات به درستی باید انجام بشه و بعد باید صفحه لود شه که با این خطا مواجه میشوم
btnSave.Visible = false;
lblMessage.Text = "خبر انتخاب شده آماده تغييرات است. براي ثبت تغييرات، تغييرات دلخواه را اعمال و بر روي دكمه 'ذخيره تغييرات' كليك نماييد.";
}
}
[/CODE]

در مورد اپدیت هم اطلاعات را لود به داخل تکس باکس ها نمیکنه و خطای زیر را دارم.
The GridView 'GridView1' fired event RowDeleting which wasn't handled.

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.Web.HttpException: The GridView 'GridView1' fired event RowDeleting which wasn't handled.

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:

[HttpException (0x80004005): The GridView 'GridView1' fired event RowDeleting which wasn't handled.] System.Web.UI.WebControls.GridView.OnRowDeleting(G ridViewDeleteEventArgs e) +1463321 System.Web.UI.WebControls.GridView.HandleDelete(Gr idViewRow row, Int32 rowIndex) +637 System.Web.UI.WebControls.GridView.HandleEvent(Eve ntArgs e, Boolean causesValidation, String validationGroup) +952 System.Web.UI.WebControls.GridView.RaisePostBackEv ent(String eventArgument) +210 System.Web.UI.WebControls.GridView.System.Web.UI.I PostBackEventHandler.RaisePostBackEvent(String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +176 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

Z_Bagheri
دوشنبه 25 مهر 1390, 20:13 عصر
تا اونجایی که من می دونم نمیشه از ایونت delete گرید ویو استفاده کرد، من بر ای حذف رکرد از گرید ویو یک ستون به گرید اضافه می کنم از نوعtemplate field و بهش یک button اضافه می کنم و command arguman اش رو با فیلد آیدی جدول با دستور eval ست می کنم و روی ایونت command اون دیتا رو از دیتا بیس حذف می کنم و مجددا کل گرید رو به table بایند می کنم.بدون هیچ مشکلی این کار انجام میشه.

ERIKA
دوشنبه 25 مهر 1390, 20:40 عصر
با اجازتون من هم همین کار را کردم اینم عکسش

من خودم همین کد را یک جایی دیگه استفاده کردم هیچ مشکلی هم نداشت اجرا میده فقط با این تفاوت که اونجا هیچ سیژنی تعریف نکر ده بودم
الیته شما هر دو کدی که گذاشتم را ببینید و قضاوت کنید
اینم کدهاش 76726

ricky22
دوشنبه 25 مهر 1390, 23:39 عصر
سلام.
اسم Command حذف رو چیزی غیر از Delete بگزارید.
مثلا DeleteRecord
موفق باشید.