Questions tagged [datarowcollection]

Represents a collection of rows for a DataTable in .NET applications.

The DataRowCollection is a major component of the DataTable. While the DataColumnCollection defines the schema of the table, the DataRowCollection contains the actual data for the table, where each DataRow in the DataRowCollection represents a single row.

You can call the Add and Remove methods to insert and delete DataRow objects from the DataRowCollection. You can also call the Find method to search for DataRow objects that contain specific values in primary key columns, and the Contains method to search character-based data for single words or phrases.

via MSDN

20 questions
52
votes
4 answers

Convert DataRowCollection to DataRow[]

What's the best performing way to convert a DataRowCollection instance to a DataRow[]?
Jeff
16
votes
4 answers

How to get columns from a datarow?

I have a row collection (DataRow[] rows). And I want to import all rows to another DataTable (DataTable dt). But how? Code DataTable dt; if (drs.Length>0) { dt = new DataTable(); foreach (DataRow row in drs) { …
uzay95
  • 16,052
  • 31
  • 116
  • 182
9
votes
3 answers

Will Microsoft ever make all collections useable by LINQ?

I've been using LINQ for awhile (and enjoy it), but it feels like I hit a speedbump when I run across .NET specialized collections(DataRowCollection, ControlCollection). Is there a way to use LINQ with these specialized controls, and if not do you…
Bless Yahu
  • 1,331
  • 1
  • 12
  • 25
3
votes
2 answers

Get distinct values from a column of DataTable in .NET 2.0

I am working on a legacy project which was developed using .NET Framework 2.0. In this project, I get distinct values from DataRowCollection by ItemNo column. I am only interested in ItemNo. The DataRow consist of ItemNo, Qty and Date. I am thinking…
Alan B
  • 2,219
  • 4
  • 32
  • 62
3
votes
3 answers

Cannot remove rows from DataTable because "Collection was modified; enumeration operation might not execute"

This is my code to remove row from datatable: DataTable dtapple = dt; foreach (DataRow drapplicant in dtapple.Rows) { int iapp = Convert.ToInt32(drapplicant["SrNo"].ToString()); if (drapplicant["PassportExpDate"].ToString().Trim() != "") …
Bhupendra
  • 350
  • 3
  • 16
2
votes
1 answer

Why does DataTable.Rows not have a .Where() method?

I like the syntax offered by the .Where() method that is available for many collections. However, I've noticed that it is conspicuously absent from some collections. I'm sure that this has to do with some interface being implemented or not…
Vivian River
  • 31,198
  • 62
  • 198
  • 313
2
votes
1 answer

No type inference with DataRowCollection

I have a project that stores some data from SQL in a DataTable and then maps each DataRow to a custom class instance. When I loop over the Rows property (which is of type DataRowCollection), there's no type inference. So this doesn't work: var dt =…
Aage
  • 5,932
  • 2
  • 32
  • 57
1
vote
1 answer

Why can I not iterate over something with linq that can be iterated over with foreach?

I have a collection of table rows (type DataRowCollection). It is perfectly valid for me to write: foreach(var row in myDataRowCollection) { // Something with row } Yet the following will not compile: myDataRowCollection.ToList(); or…
user10058046
1
vote
1 answer

How do I populate a DataRow and assign it to one of two tables based on a condition?

I have data being processed by an app which needs to sort the data based on whether or not a bit is flipped. The tables are identical. The code as it stands looks something like this: DataTable dt2 = dt1.Clone(); DataRow r =…
CDove
  • 1,940
  • 10
  • 19
1
vote
2 answers

Map RowDataCollection to DTO using AutoMapper

Is there a way to map a RowDataCollection to DTO using AutoMapper? Here is a scenario: DataRow to Object user.UserId = row["UserId"]; user.UserName = row["UserName"];
Aivan Monceller
  • 4,636
  • 10
  • 42
  • 69
1
vote
0 answers

How to capture angularjs smart-table updated cell values?

I am using smart-table to display a grid. The grid is editable. I want the updated grid to be captured back to the .js file. So that I can do some manipulation on the updated values and display it in another grid. Below is the .js code. …
0
votes
1 answer

exception:Row provided already belongs to a DataGridView control

I am getting following exception while coping the row in same datagrid view control System.InvalidOperationException was unhandled Message="Row provided already belongs to a DataGridView control." Following is copy method that copies selected…
Coder Guru
  • 513
  • 3
  • 18
  • 37
0
votes
1 answer

How to use TypedDataTable.Rows.Find(key as object) to find a row which has a composite key?

I have a TypedDataTable called CamerasDT which has a composite Primary Key of GroupId and CameraId. I want to use TypedDataTable.Rows.Find(key as object) to return a specific row by GroupId and CameraId. I don't seem to be able to find a way to send…
mohsensajjadi
  • 325
  • 1
  • 6
  • 18
0
votes
1 answer

copy one or more selected row from Janus Grid to DataRowCollection or DataRow[]

I have a Janus Grid with a checkbox in each row and wanna copy selected row(s) to a DataRowCollection or to DataRow[] .this is my way but not completed and not worked: also this grid has group on one field and I use 2 loop for group and…
MHD
  • 25
  • 9
0
votes
1 answer

How to fix late binding for datarow in datacollection where datarow variable defined in range

I'm in the process of converting VB to C#.Net for my company. In order to do this more easily, I have option strict ON. I am trying to resolve a late binding on the following code. Row is considered an OBJECT by the compiler. I've never written code…
1
2