Showing posts with label Code Snippets. Show all posts
Showing posts with label Code Snippets. Show all posts

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