Tuesday 12 March 2013

Delete Particular or Selected Row from Datatable in Asp.net

We can delete datatable rows by using delete method for that check below code
 

C# Code

DataTable dt1 = new DataTable();
dt1 = ds.Tables[0];
for (int i = 0; i < dt.Columns.Count;i++ )
{
if (i == 3)
{
dt.Rows[i - 1].Delete();
dt.AcceptChanges();
}
}


VB.NET Code

Dim dt1 As New DataTable()
dt1 = ds.Tables(0)
For i As Integer = 0 To dt.Columns.Count - 1
If i = 3 Then
dt.Rows(i - 1).Delete()
dt.AcceptChanges()
End If
Next

2 comments:

  1. Mr Lokesh Kumar Gupta,

    You are writing articles just copying and pasting articles from www.aspdotnet-suresh.com remove all the articles whatever you copy and paste otherwise i will give compalint on you with DMCA Notice

    ReplyDelete
  2. Thanks sir for telling my mistake. i really sorry.
    problem now with me is that i forgot my sign in credentials to remove these blog post as well as remove this whole blog.
    So you will never final any your article on here.
    I really sorry for my mistake.

    ReplyDelete