How to dynamically create many datatables in c#.net
-
How to create many datatable dyanamically in c#.net. Thanks in Advance.
-
How to create many datatable dyanamically in c#.net. Thanks in Advance.
-
Can you be more specific to your Qs/requirement? although at runtime time you can create datatable using DataTable class.Use google/msdn
Cheers!! Brij
Brij wrote:
Brij wrote:
I want to create datatabke array, where the array count will be statis and be declared in configuration. like . int iCount=4; for(x=1;x<=icount;x++) { // Here datatable object will be created dynamicall. like dt1,dt2.dt3.... DataTable dt+x =new DataTable(); // I want to add columns to the particular datatable. dt+x.columns.add("NO"); dt+x.columns.add("NAME .. } Thanks.
-
Brij wrote:
Brij wrote:
I want to create datatabke array, where the array count will be statis and be declared in configuration. like . int iCount=4; for(x=1;x<=icount;x++) { // Here datatable object will be created dynamicall. like dt1,dt2.dt3.... DataTable dt+x =new DataTable(); // I want to add columns to the particular datatable. dt+x.columns.add("NO"); dt+x.columns.add("NAME .. } Thanks.
-
Why don't you use List?Use list of Datatable.Here you don't need to worry about the size.Create datatable at runtime and add to the list.Whenever you need you iterate the list and use them accordingly.
Cheers!! Brij
That's OK.But if I don't put the value in configuration then how would i know the count of datatables ???
-
That's OK.But if I don't put the value in configuration then how would i know the count of datatables ???
You can get the count from the list itself.You can store it some session variable (if user specific) or application varaiable(if application specific) for any other use. One thing How are you getting the count of the table.Is it coming at runtime?Can you be more specific to requirement?
Cheers!! Brij