Grid View Delete

B

bbawa1

I have the followning code in my HTML part. But when I click on Deletw
link it deleted the record from gridview as well as from Datasource
but it give me following error page


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.NotSupportedException: Updating is not
supported by ObjectDataSource 'ObjectDataSource1' unless the
deleteMethod is specified.




Here Is the code

DataKeyNames="UserId" DataSourceID="ObjectDataSource1"
OnRowCommand="gdAddUser_RowCommand"
OnRowDataBound="gdAddUser_RowDataBound"
OnRowDeleting="gdAddUser_RowDeleting"
Width="390px"
önSelectedIndexChanged="gdAddUser_SelectedIndexChanged"
AutoGenerateEditButton="True">





CommandArgument='<%# Eval("UserId") %>'
CommandName ="Delete">
Delete



protected void gdAddUser_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton l = (LinkButton)e.Row.FindControl("LinkButton1");
l.Attributes.Add("onclick", "javascript:return " +
"confirm('Are you sure you want to delete this record " +
DataBinder.Eval(e.Row.DataItem, "UserId") + "')");
}

}
protected void gdAddUser_RowCommand(object sender,
GridViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
// get the categoryID of the clicked row
int AppId = Convert.ToInt32(e.CommandArgument);
// Delete the record
DeleteRecordByID(AppId);
// Implement this on your own
}

}
//protected void gdAddUser_RowDeleted(object sender,
GridViewDeletedEventArgs e)

//}
protected void gdAddUser_RowDeleting(object sender,
GridViewDeleteEventArgs e)
{
int AppId = (int)gdAddUser.DataKeys[e.RowIndex].Value;
DeleteRecordByID(AppId);//implement yourself


}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top