xcaliber2222
Programmer
Hello,
This is for an ASP.NET 2.0 application:
Here is my delete button link, which verifies the operation with the user:
Here is what I'm doing in the code-behind:
Shouldn't I be able to simply run a DELETE operation against the database like I am here with an UPDATE, which works fine:
This is the error I'm getting:
Any help as to what I'm missing or doing wrong would be greatly appreciated.
Thank you,
Alejandro
This is for an ASP.NET 2.0 application:
Here is my delete button link, which verifies the operation with the user:
Code:
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="btnDelete" Text="Delete" CommandName="Delete" CommandArgument='<%# Eval("Referral Id") %>' OnClientClick='return confirm("Are you sure you want to delete this referral?");' runat="Server">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
Here is what I'm doing in the code-behind:
Code:
protected void btnDelete_Click(object sender, EventArgs e)
{
//Deleting code goes here
string sqlString = "DELETE FROM [Referrals] WHERE [ReferralId] =" + referralId.ToString();
Database db = DatabaseFactory.CreateDatabase();
DbCommand dbCommand = db.GetSqlStringCommand(sqlString);
db.ExecuteNonQuery(dbCommand);
lblmsg.Text = rowAffected.ToString() + " Row(s) Deleted Successfuly";
}
Shouldn't I be able to simply run a DELETE operation against the database like I am here with an UPDATE, which works fine:
Code:
private void SaveStatus(int referralId, string status)
{
//Saving code goes here
string sqlString = "UPDATE [Referrals] SET [Status] ='" + status + "' WHERE [ReferralId] =" + referralId.ToString();
Database db = DatabaseFactory.CreateDatabase();
DbCommand dbCommand = db.GetSqlStringCommand(sqlString);
db.ExecuteNonQuery(dbCommand);
}
This is the error I'm getting:
Code:
The GridView 'gvList' 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 'gvList' 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 'gvList' fired event RowDeleting which wasn't handled.]
System.Web.UI.WebControls.GridView.OnRowDeleting(GridViewDeleteEventArgs e) +1494719
System.Web.UI.WebControls.GridView.HandleDelete(GridViewRow row, Int32 rowIndex) +604
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +1134
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +117
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +132
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +177
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746
Thank you,
Alejandro