Click here to Skip to main content
16,018,249 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In code:
C#
TransportBindingSource.DataSource  =db.Transports;

how can save db.Transports to a public variable and use it as datasource of
other object in other form?
Posted
Updated 7-Jan-12 20:46pm
v2
Comments
OriginalGriff 8-Jan-12 3:02am    
Depends on the datatype - what is db declared as?

C#
using System.Linq;
using System.Collections.Generics;


C#
var source = db.Transports;
TransportBindingSource.DataSource =source ;


XML
Ilist list = source.ToList(); 



could help ?
 
Share this answer
 
You should create a separate static class that holds your data information so that it is separate from your Form classes. That way, any UI class you create will be able to get at the data. If your data object is included in one of the form classes, then there is quite simply a problem with the design of the solution.
 
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