?
Solved

ASP.NET 2.0 GridView Delete Row

Posted on 2007-10-03
5
Medium Priority
?
1,973 Views
Last Modified: 2008-01-09
Hi

I have a gridview, objectdatasource, a class and an XML file containing data. The select and insert statements work fine, but I cannot get the delete statement to work. How do I pass the row number from the gridview to the class?

0
Comment
Question by:riffrack
  • 3
  • 2
5 Comments
 
LVL 23

Expert Comment

by:Christopher Kile
ID: 20010088
How is your delete statement structured?  The row number is unimportant unless it is the key of the row you want to delete.
0
 

Author Comment

by:riffrack
ID: 20010141
       Public Sub DeleteAuthor(ByVal row_id As Integer)
            dsAuthors.Tables(0).Rows(row_id).Delete()
            dsAuthors.WriteXml(filePath, Data.XmlWriteMode.WriteSchema)
        End Sub
0
 
LVL 23

Accepted Solution

by:
Christopher Kile earned 2000 total points
ID: 20014392
You don't get a row number passed to you - you get the primary key of the data row passed to you.  See this link:

http://www.codeproject.com/aspnet/GridViewConfirmDelete.asp

0
 

Author Comment

by:riffrack
ID: 20027783
hi

thanks for this link. I had a look and i still can't quite figure this out.

my gridview is attached to an objectdatasource control, this calls a class in the app_code folder, which stores the business layer. The data is stored in an XML file and the data does not contain a primary key.

any more ideas?
0
 
LVL 23

Expert Comment

by:Christopher Kile
ID: 20035202
Your business layer should then provide a unique key for each record (say, increment an integer from 1 to however many records you have in your XML file, then pass that integer as an additional column of the records you supply to the ObjectDataSource when a Select request is made of it.  It is the capable to do things like this that must have made you decide to use ObjectDataSource instead of XMLDataSource in the first place (I assume).

Do you understand what I'm saying?:
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month16 days, 11 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question