Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,


I have a data table dt1 with some columns and rows. I need to view/select only the custom columns from the data table dt1 dynamically.

data table dt1 has columns: itemname, brand, model, category, stockqty.
[all the columns are taken from different tables]

I need to select only itemname and stockqty from datatable dt2 and corresponding rows.

Any one please help me...
Posted
Updated 8-Nov-12 7:43am
v2
Comments
saud_a_k 7-Nov-12 6:40am    
Make a new DataTable with itemname and stockqty as the colums and add the rows of dt1 using a foreach
if this is not what you want , please explain more
Jineesh TR 7-Nov-12 8:32am    
Hi Saud_a_k,
Thank you for your reply,
This will work fine.. But the problem is that this code will make more load.. And I want to know if there is any method for data table to select columns like this..

Regards, jini4
saud_a_k 8-Nov-12 0:28am    
LINQ
I think thats the solution given below

1 solution

var FilteredDt=dt1.DefaultView.ToTable(false, "itemname", "stockqty");
 
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