What is the method for adding data to a DataRow in C#?

In C#, you can add data using the SetField method of the DataRow object. Here is an example code:

DataRow row = dataTable.NewRow();
row.SetField("ColumnName", value);
dataTable.Rows.Add(row);

In the example above, we first create a new DataRow object and set the value for a specified column (“ColumnName”) using the SetField method. Then we add this DataRow object to the rows collection of the DataTable.

Leave a Reply 0

Your email address will not be published. Required fields are marked *