Link to home
Start Free TrialLog in
Avatar of riffrack
riffrack

asked on

ASP.NET 2.0 GridView Delete Row

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?

Avatar of Christopher Kile
Christopher Kile
Flag of United States of America image

How is your delete statement structured?  The row number is unimportant unless it is the key of the row you want to delete.
Avatar of riffrack
riffrack

ASKER

       Public Sub DeleteAuthor(ByVal row_id As Integer)
            dsAuthors.Tables(0).Rows(row_id).Delete()
            dsAuthors.WriteXml(filePath, Data.XmlWriteMode.WriteSchema)
        End Sub
ASKER CERTIFIED SOLUTION
Avatar of Christopher Kile
Christopher Kile
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
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?: