Site Search:
Sign in | Join | Help
4Penny.net

ASP.NET

Notes, Tricks and Tips on ASP.NET Coding

How to delete a row in a datatable

It took me too long to Google this - had to look on www.experts-exchange.com for it. (very nice site)

[code language="vb.net"]

Dim intRowID As Int64

        intRowID = e.CommandArgument
        ' Loop though the table

        Dim intCounter As Int16 = 0
        While intCounter < oDT.Rows.Count
            oRow = oDT.Rows(intCounter)
            If oRow("rowID") = intRowID Then
                oRow.Delete()
                intCounter = oDT.Rows.Count
            End If

            intCounter += 1
        End While

        oDT.AcceptChanges()

 

[\code]

Comments

No Comments

About Steve Gray

Steve is a seasoned (translate: old) developer in VB and ASP.NET. He spends most of his time in Dynamics GP, writing custom mods for consulting firms. Crystal reports, eConnect, VS Tools for Dynamics... anything that comes along.