Pages

Wednesday, 22 May 2013

How To Delete Particular Row from Datatable Or Delete Selected Row From DataTable in C# and VB Asp.net

How To Delete Particular Row from Datatable Or Delete Selected Row From DataTable in C#  and VB Asp.net


Program:

.Aspx File C#

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

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

No comments:

Post a Comment