I am studying ASP.NET I am trying to use this example
http://msdn.microsoft.com/en-us/libr...atasource.aspx
but for practice I want to extend it so it handles deletes.
I have this
using System;
using System.Data;
using System.Configur ation;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Web.UI.H tmlControls;
public partial class _Default : System.Web.UI.P age
{
CsvDataSource cds = null;
protected void Page_Load(objec t sender, EventArgs e)
{
if (cds == null)
{
cds = new CsvDataSource() ;
}
cds.FileName = "~/App_Data/CSVTextFile.csv ";
cds.IncludesCol umnNames = true;
GridView1.AutoG enerateDeleteBu tton = true;
// GridView1.RowDe leting += new
GridViewDeleteE ventHandler(gv_ RowDeleting);
GridView1.DataS ource = cds;
GridView1.DataB ind();
}
void gv_RowDeleting( Object sender, GridViewDeleteE ventArgs e)
{
ClientScript.Re gisterStartupSc ript(GetType(), "MyAlert2",
"alert('Deletin g');", true);
}
}
And I have changed this in the CSVDataSource Example
public override bool CanDelete
{
get
{
return true; //changed this
}
}
And have to do some stuff here that I know
protected override int ExecuteDelete(I Dictionary keys, IDictionary values)
{
throw new NotSupportedExc eption();
}
But the Execute Delete is not called. What more do I have to do to get the
GridView know that the CsvDataSource handles deletes? I am not getting this
exception:
NotSupportedExc eption: Specified method is not supported.]
System.Web.UI.D ataSourceView.E xecuteDelete(ID ictionary keys, IDictionary
oldValues) +28
System.Web.UI.D ataSourceView.D elete(IDictiona ry keys, IDictionary
oldValues, DataSourceViewO perationCallbac k callback) +75
System.Web.UI.W ebControls.Grid View.HandleDele te(GridViewRow row, Int32
rowIndex) +927
But this exception:
System.Web.UI.W ebControls.Grid View.OnRowDelet ing(GridViewDel eteEventArgs e)
+325
System.Web.UI.W ebControls.Grid View.HandleDele te(GridViewRow row, Int32
rowIndex) +732
MarcWentink