Questions tagged [datacolumn]

212 questions
3
votes
1 answer

DataColumn.Expression Property. Convert current column's bool value to string

I'm trying to add expression,which changes boolean value of current column to string value, for DataColumn: col = new DataColumn("isDirectionIn", typeof(string), "IIF(isDirectionIn = true, 'in', 'out')"); But I…
Alekstim
  • 452
  • 1
  • 8
  • 19
3
votes
2 answers

Customize DataColumn.Expression handling in C#

I would like to change behavior of DataColumn.Expression so that when I write: DataColumn.Expression = "MyMethod(Price)" It will call MyMethod, pass value from Price column into it and display evaluated value. How can I acomplish this?
Tom Smykowski
  • 25,487
  • 54
  • 159
  • 236
3
votes
3 answers

C#: How do I iterate the contents in a DataColumn?

I have a database column I simply need to check to see if a value is there. DataTable dt = masterDataSet.Tables["Settings"]; DataColumn SETTINGS = dt.Columns["DEFAULTSETTINGS"]; I just need to iterate over the values in this column…
zion
2
votes
2 answers

reference value in DataColumn Expressions

given an expression like so DataTable1.Columns.Add("value", typeof(double), "rate * loan_amt"); in a datatable with 10000 rows where rate is same for all rows and loan_amt varies When the rate changes, it changes for all currently that means…
Kumar
  • 10,997
  • 13
  • 84
  • 134
2
votes
2 answers

changing values of a column in datatable in vb.net

I want to loop through a databale and change the values of a specific column in that datatable. eg: the database returns Request_ID, Desc, Date and Status_Ind. The Status_Ind column contains integer values. I dont want to show the integer values to…
Joshua
  • 2,275
  • 7
  • 41
  • 57
2
votes
4 answers

How can I get a sum for the column "pieces" in a datatable?

How can I get a sum for the column "pieces" in a datatable? Say I had the following table. How can I calculate the "total" pieces for article="milk" and artno="15"? Columns: article artno pieces Rows: 1 milk 15 1 2 …
McSteel
  • 35
  • 1
  • 1
  • 7
2
votes
4 answers

Any built in functions to convert Datacolumn to split strings in C#.net 2.0

I have a datacolumn, which I would like to split e.g. ALICE MEGAN JANET split to: ALICE, MEGAN, JANET I know I can do it with for loops but I'd like to know if there's any built-in functions in .Net Framework. Thanks. EDIT: My question is not…
hyperkittie
  • 641
  • 6
  • 16
2
votes
2 answers

Reorder columns in datatable?

I'm using xsd files to validate xml files. In the xsd files, only a few of the elements are required and the rest are optional. However, it is sequential so the order of the elements as they appear in the datatable matter lots. After considering a…
tf.rz
  • 1,347
  • 6
  • 18
  • 47
2
votes
2 answers

Check if column exists when iterating datatable?

I'm taking a datatable and serializing it as geojson. I'm using linq for this: var envelope = new { type = "FeatureCollection", features = dataTable.AsEnumerable().Select(record => new { type = "Feature", properties = new …
fdkgfosfskjdlsjdlkfsf
  • 3,165
  • 2
  • 43
  • 110
2
votes
1 answer

DataColumn in DataTable not found by name

I'm reading from a CSV file where the first line is the header row. All column names are read and put into a table like this: foreach (var item in lines[0].Split(';').Where(s => !string.IsNullOrEmpty(s))) { …
thomas
  • 1,399
  • 1
  • 17
  • 32
2
votes
1 answer

How to compare the columns of a datatable based on the column name and value?

I have a datatable like below one which is not fixed it can contain n number of columns. I need to compare the column values based on the column name and update the other row value E.g dtFinYearValues dtColumnName | 2017AU | 2017CN | 2018AU |…
Kumar
  • 167
  • 1
  • 1
  • 11
2
votes
2 answers

Best way to add a new column to a data table based on an existing column

I have a data-table with data. I need to add another column to the datatable having the same value of another column but with less precision. Ie the original column would be having value 12.123 but the new column will have value 12.12 What is the…
Ananth
  • 10,330
  • 24
  • 82
  • 109
2
votes
0 answers

Can a C# Datatable expression be used with global values?

I would like to use the DataColumn's expression similar to what Excel allows. Consider Excel if I have a column 'A'(raw inputs) and another 'a' that is =2*A+$B$1 then each cell in 'a' column takes the corresponding cell in 'A' and multiplies by 2…
2
votes
2 answers

DataTable remove columns and re-order the columns

I want to remove unwanted columns from a datatable and arrange the order of the columns in pre-defined order For example, my table columns are like below, Col2|Col1|Col3|Test|Test1|Col5|Col4|Some col name|Col6 I want to remove Test, Test1 and Some…
blue
  • 833
  • 2
  • 12
  • 39
2
votes
1 answer

Can I configure a strongly typed data set to use nullable values?

If I have a strongly typed data table with a column for values of type Int32, and this column allows nulls, then I'll get an exception if I do this for a row where the value is null: int value = row.CustomValue; Instead I need to do this: if…
Dan Tao
  • 125,917
  • 54
  • 300
  • 447
1 2
3
14 15