Click here to Skip to main content
13,050,617 members (85,512 online)
Rate this:
Please Sign up or sign in to vote.
See more:

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 6-Nov-12 23:50pm
Updated 8-Nov-12 7:43am
Maciej Los255.3K
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
jini4 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
I think thats the solution given below

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

var FilteredDt=dt1.DefaultView.ToTable(false, "itemname", "stockqty");

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 8 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100