PC Review


Reply
Thread Tools Rate Thread

CsvDataSource : how to extend the example so it calls handle delete?

 
 
Marc
Guest
Posts: n/a
 
      30th Aug 2008
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.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
CsvDataSource cds = null;
protected void Page_Load(object sender, EventArgs e)
{
if (cds == null)
{
cds = new CsvDataSource();
}
cds.FileName = "~/App_Data/CSVTextFile.csv";
cds.IncludesColumnNames = true;
GridView1.AutoGenerateDeleteButton = true;
// GridView1.RowDeleting += new
GridViewDeleteEventHandler(gv_RowDeleting);
GridView1.DataSource = cds;
GridView1.DataBind();
}

void gv_RowDeleting(Object sender, GridViewDeleteEventArgs e)
{
ClientScript.RegisterStartupScript(GetType(), "MyAlert2",
"alert('Deleting');", 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(IDictionary keys, IDictionary values)
{
throw new NotSupportedException();
}


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:

NotSupportedException: Specified method is not supported.]
System.Web.UI.DataSourceView.ExecuteDelete(IDictionary keys, IDictionary
oldValues) +28
System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary
oldValues, DataSourceViewOperationCallback callback) +75
System.Web.UI.WebControls.GridView.HandleDelete(GridViewRow row, Int32
rowIndex) +927

But this exception:

System.Web.UI.WebControls.GridView.OnRowDeleting(GridViewDeleteEventArgs e)
+325
System.Web.UI.WebControls.GridView.HandleDelete(GridViewRow row, Int32
rowIndex) +732

MarcWentink

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
datagridview delete calls DefaultValuesNeeded mrstrong Microsoft Dot NET 1 21st Sep 2011 01:59 PM
How to delete all function calls Anand Ganesh Microsoft C# .NET 3 1st Feb 2007 01:25 AM
Delete blank calls in row, shifting left Steph Microsoft Excel Programming 1 1st Jun 2005 07:40 PM
How do I extend the RangeValidator control to handle custom dates? =?Utf-8?B?ams=?= Microsoft ASP .NET 6 24th Dec 2004 03:25 AM
How to get a handle to $Extend files? Ben Smith Microsoft Windows 2000 File System 0 2nd Feb 2004 06:31 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:47 AM.