473,725 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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

Aug 30 '08 #1
0 849

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

52
27017
by: Newsnet Customer | last post by:
Hi, Statement 1: "A dynamically created local object will call it's destructor method when it goes out of scope when a procedure returms" Agree. Statement 2: "A dynamically created object will call it's destructor when it is made a target of a delete".
1
2609
by: Pelle | last post by:
Hello all, I have to admit, that the idea that occurred to me recently is weird. It was somehow inspired by the huge response on the "delete operator" thread, but goes into a somewhat different direction. From my understanding there are 2 "ways" of handling memory: -- one (from C) is the malloc/realloc/free set of API functions -- the other one (from C++) is the new/new/delete/delete set of API functions.
4
2789
by: MAB71 | last post by:
I'm running an ISP database in SQL 6.5 which has a table 'calls'. When the new month starts I create a new table with the same fields and move the data of previous month into that table and delete it from calls. So 'calls' holds the data of only the current month. for example at the start of november 2003 I ran the queries Create Table Oct2003Calls { ................ ................
20
4150
by: Ioannis Vranos | last post by:
When we use the standard placement new operator provided in <new>, and not a definition of owr own, isn't a call to placement delete enough? Consider the code: #include <new>
6
1869
by: Jay Nabonne | last post by:
Hi, This might sound odd, but we want to replace the allocation scheme used by new and delete without changing operator new and operator delete. (The global operators are shared and we can't change them.) We can replace operator new functionality by providing additional parameters to the new function call (ala Stroustrup): class foo_t;
10
2247
by: MaxMax | last post by:
int *p; p = new int; void *q = (void*)p; delete q; Is this valid if p is guaranteed to be a POD? (don't ask why... there is a reason I need this. Clearly I will create p in function, use p in another function that know what type p is and delete p in a function that for simplicity won't know what p is)
9
8170
by: rohits123 | last post by:
I have an overload delete operator as below ////////////////////////////////// void operator delete(void* mem,int head_type) { mmHead local_Head = CPRMemory::GetMemoryHead(head_type); mmFree(&local_Head,(char *)mem); CPRMemory::SetMemoryHeadAs(local_Head,head_type); } ///////////////////// void* operator new(size_t sz, int head_Type) {
29
2265
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, I remembered delete is implemented through operator overloading, but I am not quite clear. Could anyone recommend some links about how delete is implemented so that I can learn and refresh my memory? :-)
4
1837
by: mail.dsp | last post by:
Suppose in a class we overload four operators: operator new operator delete operator new operator delete class Test{ public: void * operator new (size_t t){ cout<<"\nCalling... new";
0
8888
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9174
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8096
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4517
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4782
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2634
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.