Click here to Skip to main content
15,883,870 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I have one datable consist around 25000 record

datable look like this

Id   Name   Lname   bday
1    abc    hdhd    25-02-1991
2    cnd     dhdhd  7-05-1995
3    dhdhd   ddjd   15-07-1993
4    dhhdd   ddddhd 05-09-1999

i am converting above datable after fetching record from Excel

now i want to add 2 more column plus record also column are created_by, created_date(todays date)

For e.g

Id   Name   Lname   bday         created by      created date
1    abc    hdhd    25-02-1991     rajesh           2023-06-28
2    cnd     dhdhd  7-05-1995      rajesh           2023-06-28
3    dhdhd   ddjd   15-07-1993     rajesh           2023-06-28
4    dhhdd   ddddhd 05-09-1999     rajesh           2023-06-28

can i do that without using any loop or datable column expression will do that??

What I have tried:

i google it ,i found column expression like something there but i get example of loop i dont wana use loop because there somthing 4,5 lack record
Updated 27-Jun-23 20:59pm
Graeme_Grant 28-Jun-23 2:30am    
This is your 49th question. By now you know, no code, no help. We don't write your code for you. Update your question please.
Akshay malvankar 28-Jun-23 2:35am    
hi Graeme_Grant your right but not evertime we can shared code because you know client may take action,just wana help on though can we do this or not?? otherwise thanks for your reply ,i get answer from other platform just puting above question
Graeme_Grant 28-Jun-23 3:03am    
If you share code, explain why it does not work, supply full error messages, then we can look at it and point you in what we think is the right direction based on the information supplied. No code = no help. If you do not want to share client code, make a mock project to show the issue, this is not a breach of confidentiality or copyright infringement.

DO NOT waste your time and ours. You are being paid, not us, so you need to stop being lazy and make the effort. Programming is problem solving, not asking others to solve your problems. Do the work!
Richard MacCutchan 28-Jun-23 3:37am    
It would take less than 5 minutes to create a mocked up code sample to demonstrate your problem. And it is highly unlikely that any client would complain if you showed a few lines of code that have absolutely no commercial value.
Graeme_Grant 28-Jun-23 3:39am    
I just re-read his comment and apparently spammed multiple sites like CP and got an answer on one. Do we want to flag him as a spammer?

1 solution

This is your 49th question, pretty much all of which can be answered with a trivial google, or a little knowledge of the classes you are playing with.

In this case, it's simple to work out what you need to do by thinking about a DataTable and what it is made up of: DataRow and DataColumn elements.
Since you want to create a new column with a preset default value, you look at the DataColumn class[^]
You will find it has properties, including the DataColumn.DefaultValue Property[^] which does exactly what you think it will.

So, why waste half an hour or longer waiting for us to tell you that, when one minute of thinking on your part and a quick bit of reading would have got you what you needed?
You are showing all the signs of being a Help Vampire - and trust me, you don't want people thinking of you that way!
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900