Link to home
Start Free TrialLog in
Avatar of curiouswebster
curiouswebsterFlag for United States of America

asked on

I need to assign meta data to a DataTable

I need a DataTable to store its "preferred column names", for use when I add that data to a new table.


Names could be:

CASES_SHIPPED

BOTTLES_SHIPPED


or 

CASES_ORDERED

BOTTLES_ORDERED


What field(s) can I use in a DataTable where I can Set those value at the start, then Get them when I need them?


Is this what meta data can be used for? How do I do it (without much effort)?


Thanks.

ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of curiouswebster

ASKER

I will create a different table later, and do not want those columns in the main table. And I want to ensure those columns never end up getting shown to the user.

Will this work?

            sourceProductList.ExtendedProperties.Add("CasesColumn", "CASES_SHIPPED");
            sourceProductList.ExtendedProperties.Add("BottlesColumn", "BOTTLES_SHIPPED");

            string casesColumnName = sourceProductList.ExtendedProperties["CasesColumn"].ToString();
            string bottlesColumnName = sourceProductList.ExtendedProperties["BottlesColumn"].ToString();

It gives me back what I expected...

If it does what you want then OK.


>>And I want to ensure those columns never end up getting shown to the user. 

I don't know what you mean with that - the user will only see those names if your code displays them somewhere on the GUI.

It create a DataTable, then an Excel. The columns would show up, but I want the column names for a different table.

OK, but you can label the columns in excel whatever you wanted to independant of the data table columns names (or not even name them in excel if you wanted that).