Introduction:
Here I will explain how to delete particular row from
datatable or delete selected rows from datatable in asp.net
using C# and VB.NET.
Description:
In previous articles I explained Check username availability with progressbar, Richtextbox example in asp.net, Asp.net Interview questions, Joins in SQL Server, Highlight Gridview records based on search and many
articles relating to Gridview,
SQL ,jQuery,asp.net,
C#,VB.NET.
Now I will explain how to delete particular row from datatable or delete
selected rows from datatable in asp.net
using C# and VB.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
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
4 comments :
hi this is sandeep, recently i got job as SE,
so can i have an example on datalist using with all events pleasea.
Thanks Suresh...Its helpful for me..............
Hi this is aneev . We cannot assign a error to the datatable for a particular row.
good
Note: Only a member of this blog may post a comment.