aspx Tutorial

.NET Articles,jQuery demo, asp.net with jQuery, online tutorial,Jquery, SilverLight, Javascript, asp.net,JSON, MVC,.NET Articles,demo, Web Services, .NET articles, Sharepoint 2010, visual studio 2010,Aamir Hasan,IT, Building Your First Web Application Project
Advertise Here

Toolbar

Get our toolbar!

Advertize



Posted by Aamir Hasan   on Friday, April 13, 2012 Total Views:  

I will extend my previous example in which I have explained you that how to create a DataTable in asp.net.

You can delete rows from a data table by using Delete Method. After deleting row, you have to call AcceptChanges Method to commit all changes in datatable. In this example. I have deleted 2nd row as i have passed 1st index of the row because index count start from the zero.AcceptedChanges method has been applied to commit changes in datatable.

Here’s an example

 

        DataTable dt = new DataTable();

        DataRow dr = null;

        dt.Columns.Add(new DataColumn("FullName", typeof(string)));

        dt.Columns.Add(new DataColumn("Age", typeof(Int16)));

        for (int i = 0; i < 10; i++)

        {

            dr = dt.NewRow();

            dr["FullName"] = String.Format("Aamir Hasan_{0}", i.ToString());

            dr["Age"] = 20;

            dt.Rows.Add(dr);

        }

 

        dt.Rows[0]["FullName"] = "Faisal Hameed";

        dt.Rows[0]["Age"] = 20;

        dt.AcceptChanges();

 

Output

Protected by Copyscape Online Plagiarism Tool

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5