Hello ,
I Have one DataTable with Columns as SlNo,FirstName,LastName,MobileNO and Salary,
i want to Copy only SlNo,FirstName,LastName and Salary to anothere table .....
Using Loops i want to add Data
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Darshan KshirasagarRank #6,482 · 265 reputationPosted Nov 23, 2016, 8:58 PM EST
for (int i = 0; i < arrObj.Count(); i++)
{
string ColName = arrObj[i].ColName;
newTable = dt.DefaultView.ToTable(false, ColName);
}
Midhun TpRank #388 · 6.5K reputationPosted Nov 24, 2016, 7:26 PM EST
Ramesh S84 reputationPosted Nov 25, 2016, 3:27 AM EST
DataTable newTable = oldTable.DefaultView.ToTable(false, "SINo", "FirstName", "LastName", "Salary");Manas MohapatraRank #182 · 13.2K reputationPosted Nov 25, 2016, 7:27 AM EST
copyDataTable = table.Copy();
copyDataTable.Columns.Remove("ColB");
System.Data.DataTable selected = view.ToTable("Selected", false, "col1", "col2", "col6", "col7", "col3");