473,402 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Adding datacolumn to filled datatable

VMI
I have a a filled datatable with 3 datacolumns and I need to add a 4th
datacolumn that will contain information according to one of the columns.
For example, for one record, Col1, Col2, Col3 will contain "Mr", "John",
"Smith", respectively. The newly-added 4th column (Col4) will evaluate
Col1, and if it says "Mr.", that row wlll contain "Mister" in Col4. If it
says, "Ms", it'll contain, "Miss", and so on.
How can I do this?

Thanks.
Nov 16 '05 #1
1 7707
VMI
DataColumn col_type = new DataColumn("Type");

myTable.Columns.Add(col_type);

col_type.Expression = "IIF(Col1='Mr', 'Mister', 'Miss');

http://msdn.microsoft.com/library/de...ssiontopic.asp

"VMI" <vo******@yahoo.com> wrote in message
news:uR**************@TK2MSFTNGP11.phx.gbl...
I have a a filled datatable with 3 datacolumns and I need to add a 4th
datacolumn that will contain information according to one of the columns.
For example, for one record, Col1, Col2, Col3 will contain "Mr", "John",
"Smith", respectively. The newly-added 4th column (Col4) will evaluate
Col1, and if it says "Mr.", that row wlll contain "Mister" in Col4. If it
says, "Ms", it'll contain, "Miss", and so on.
How can I do this?

Thanks.

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dave Elliott | last post by:
After inserting a new data row to a DataTable that is bound to a datagrid, I am unable to change data in a row that is after the newly added row without getting bizarre results. I have added the...
1
by: VMI | last post by:
In my Win app, I call a method that returns a datatable with all its columns and is filled with data. After the table's returned, I need to add another column to the datatable that will include...
6
by: Robert Schuldenfrei | last post by:
Dear NG, After being away from C# programming for a spell, I am trying my hand at what should be a simple task. I have been hitting my head against the wall this morning. I have a simple order...
3
by: Robin Thomas | last post by:
I am fairly new to ASP.NET so I think I am missing something fundamental. Anyway, quite often I am pulling data from a database, but then I need to use that data to produce more data. A simple...
1
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple...
2
by: saleek | last post by:
I was wondering if there is a way I can add an extra header to a datagrid? I found this solution on the internet - but it seems quite old and didn't work for me. ...
2
by: Flack | last post by:
Hey guys, I have a DataGrid and DataTable field in my class : private ImageDataGrid dataGrid1; //ImageDataGrid extends dataGrid and just overides OnMouseDown private DataTable dt = new...
6
by: Paulers | last post by:
Hello, I have a string that I am trying to add each char to a datatable row. for example if I have a string that looks like "abcdefg", I would like to break it up into an array of characters...
1
by: snowrupa | last post by:
Here is my code.while i am trying to run this code.Error is raising.Can any one help me in this? Column 'Trans Seq No' does not belong to table . protected void Page_Load(object sender,...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.