PDA

View Full Version : سوال: exception پس از اجرای رويه ي update



mahnaz0098
شنبه 26 مرداد 1392, 10:03 صبح
سلام
من یک گریدویو دارم که یه دکمه ی حذف در انتهای هر سطر اون وجود داره و با زدن اون دکمه یه sp که عمل update رو انجام میده اجرا میشه ولی بعد از اجرای sp با اینکه update انجام میشه یه exception در صفحه نمایش داده میشه . علتش چیه؟؟




<asp:GridView ID="gvDetails" CssClass="Gridview" runat="server"
AutoGenerateColumns="False" ForeColor="White"
onrowcommand="gvDetails_RowCommand" >
<FooterStyle BackColor="#990000" ForeColor="White"/>
<RowStyle BackColor="White" ForeColor="#333333"/>
<AlternatingRowStyle BackColor="#FFFFE0" />
<HeaderStyle BackColor="#df5015" />
<Columns>
<asp:BoundField DataField="Code" HeaderText="کد سفارش" />
<asp:BoundField DataField="Customer_name" HeaderText="نام مشتری" />
<asp:BoundField DataField="Date" HeaderText="تاریخ" />
<asp:BoundField DataField="Print_Type_ID" HeaderText="نوع سفارش" />
<asp:BoundField DataField="Title" HeaderText="عنوان" />
<asp:HyperLinkField HeaderText="جزئیات" Text="جزئیات"
DataNavigateUrlFields="Code"
NavigateUrl="~/UI/Pages/Rahgiri_instruction.aspx" DataNavigateUrlFormatString="~/UI/Pages/Rahgiri_instruction.aspx?code={0}" Target="_blank"/>


<asp:HyperLinkField HeaderText="نمونه 1" Text="دانلود"
DataNavigateUrlFields="Code,File1"
DataNavigateUrlFormatString="~/UI/Images/instruction/{0}(1)_{1}"
Target="_blank" />
<asp:HyperLinkField HeaderText="نمونه 2" Text="دانلود" DataNavigateUrlFields="Code,File2"
DataNavigateUrlFormatString="~/UI/Images/instruction/{0}(2)_{1}"
Target="_blank" />
<asp:templatefield headertext="حذف">
<itemtemplate>
<asp:Button id="btnDel" OnClientClick="return confirm('آیا از حذف سفارش اطمینان دارید؟')"
Text= "حذف"
CommandName="delete"
CommandArgument='<%#Eval("ID")%>'

runat="server"/>
</itemtemplate>
</asp:templatefield>


</Columns>
</asp:GridView>






protected void gvDetails_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "delete")
{
int code = Convert.ToInt32(e.CommandArgument);
con.Open();

SqlCommand cmd = new SqlCommand("[dbo].[Delete_Instruction]", con);
cmd.CommandType = CommandType.StoredProcedure;

int FID = code;

cmd.Parameters.AddWithValue("@Code", code);
cmd.ExecuteNonQuery();
con.Close();



}
}



The GridView 'gvDetails' 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.