DataRow is an ADO.Net class that represents a row of a data in a DataTable.
Questions tagged [datarow]
755 questions
6
votes
5 answers
Extract from DataRow or DataReader with one function
I'm looking for a solution for how to be able to extract data from a database when using either a DataRow and a DataReader with only one function (or one base function).
My problem stems from the fact that sometimes I need a DataReader and sometimes…

Nate32
- 251
- 2
- 5
- 12
6
votes
1 answer
delete datarow from datatable
Lets say I have a datatable dt (it contains advertisers) and I want to remove a row from dt where the advertiserID equals a value, how do I do that?
DataTable dt = new DataTable();
//populate the table
dt = DynamicCache.GetAdvertisers();
//I can…

flavour404
- 6,184
- 30
- 105
- 136
6
votes
2 answers
What is the difference between RowState.Added and DataRowVersion.Original
I have a function with 3 conditions:
If DataRow rowstate == Added
If !DataRow HasVersion(DataRowVersion.Original)
If DataRow rowstate == modified
My problem is with the second one, can anyone shine some light on it?
How is it different than the…

Amit Toren
- 353
- 5
- 13
6
votes
3 answers
How to extend DataRow and DataTable in C# with additional properties and methods?
I would like create a custom DataRow that will have -let's say- a propery called IsCheapest.
public class RateDataRow : DataRow
{
protected internal RateDataRow(DataRowBuilder builder) : base(builder)
{
}
public bool IsCheapest {…

pencilCake
- 51,323
- 85
- 226
- 363
6
votes
5 answers
Iterate through a DataTable to find elements in a List object?
As I iterate through a DataTable object, I need to check each of its DataRow objects against the items in a generic string List.
I found a blog post using the List's Find method along with a delegate, but whereas that example has a separate class…

Darth Continent
- 2,319
- 3
- 25
- 41
6
votes
2 answers
how to return single row using TableAdapter
Hi I am currently using TableAdapter that returns a dataTable, which is fine to use when result table should have more than one row like :
MyItemsDataTable myItemsDataTable = Adapter.GetAllItems();
but if we need only one row as a result, say an…

Asad
- 21,468
- 17
- 69
- 94
5
votes
4 answers
Datarow to CSV line C#
Is there any form of statement which converts a datarow to a CSV line so it could be written to a .csv file? (with or without steps in between)

Dashzapp
- 123
- 4
- 13
5
votes
3 answers
Can you use DataTable.Contains(object key) if your datatable's primary key is two columns?
if so how?

Slim
- 5,635
- 7
- 31
- 30
5
votes
1 answer
How can I use ExtendedProperties on a DataRow
A C# DataTable has a PropertyCollection ExtendedProperties. A DataColumn in that table also has an ExtendedProperties Why would DataRow not have this?
So, for example, If I have multiple tables and want to add some metadata to be used in the view,…

David Starkey
- 1,840
- 3
- 32
- 48
5
votes
3 answers
Setting value of an item in a DataRow does not work
I am trying to convert all DateTime values in a DataTable to strings. Here is the method I use:
private static void ConvertDateTimesToStrings(DataTable dataTable)
{
if (dataTable == null)
{
return;
}
for (int rowIndex = 0;…

Serhat Ozgel
- 23,496
- 29
- 102
- 138
5
votes
5 answers
How to check if a column with a given name exists in a datarow
I want to insert a value from loop in datarow so before entering value in datarow, I want to check that a perticular column NAME exist in table or not. Please tell me how can I check it. (vb.net preferred).

Dr. Rajesh Rolen
- 14,029
- 41
- 106
- 178
5
votes
1 answer
Is it possible to insert DataRow into a DataTable at index 0?
This question answers how to insert a DataColumn at position 0. Is there a way to do the same thing with a DataRow? Or is that impossible? Thanks.

rosscj2533
- 9,195
- 7
- 39
- 56
5
votes
6 answers
Filtering a datatable row using a where clause
I have a DataTable that I am pulling from a DataSet. From the DataTable, I want to use the Where clause to return a particular row. I looked at "How can I select a row from a datatable using two variable values?" but I get an error
"Cannot…

Csharp
- 2,916
- 16
- 50
- 77
4
votes
3 answers
Trouble with updating DataRow in C#
I have a very simple C# DataTable problem that I cannot seem to wrap my head around; it seems so strait forward but I must be missing something.
I was hoping that someone could explain to me why I'm unable update a cell value in a DataTable like…

Chromex
- 43
- 1
- 3
4
votes
3 answers
What's wrong with my C# code?
There is something wrong with my code here:
byte[] bits = Convert.ToByte(ds.Tables[0].Rows[0].Item[0]);
There's an error saying that:
System.Data.DataRow does not contain a definition for 'Item'and no
extension method 'Item' accepting a first…

James Andrew Cruz
- 135
- 1
- 3
- 9