ZURINET
asked on
Bind dataview from Class objects
Hi all
I am looking for a way to bind the below class object to a dataview
A tutorial or code snipet will be appreciated.
Please note.. I alread have a class that read the data from database..
db connection topic is not relevant
Thanks in Advance
I am looking for a way to bind the below class object to a dataview
A tutorial or code snipet will be appreciated.
Please note.. I alread have a class that read the data from database..
db connection topic is not relevant
Thanks in Advance
class Airplane
{
public Airplane(string model, int fuelKg)
{
_id = ++lastID; Model = model; _fuelKg = fuelKg;
}
private static int lastID = 0;
public int _id;
public int ID { get { return _id; } }
public int _fuelKg;
public int FuelLeftKg { get { return _fuelKg; } set { _fuelKg = value; } }
public string _model;
public string Model { get { return _model; } set { _model = value; } }
public List<Passenger> _passengers = new List<Passenger>();
public List<Passenger> Passengers { get { return _passengers; } }
}
class Passenger
{
public Passenger(string name)
{
_id = ++lastID; Name = name;
}
private static int lastID = 0;
public int _id;
public int ID { get { return _id; } }
public string _name;
public string Name { get { return _name; } set { _name = value
ASKER
Hi Rouchie
Thanks for the feedback..
I am looking for C# based solution.
Thanks
Thanks for the feedback..
I am looking for C# based solution.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hi.. you can fill dataview with the help of this function. try this..
public object getdata(string str)
{
string constr;
constr = "ConnectionString";
SqlConnection con = new SqlConnection(constr);
con.Open();
object a;
SqlCommand cmd = new SqlCommand(str,con);
a = cmd.ExecuteScalar();
con.Close();
return a;
}
public object getdata(string str)
{
string constr;
constr = "ConnectionString";
SqlConnection con = new SqlConnection(constr);
con.Open();
object a;
SqlCommand cmd = new SqlCommand(str,con);
a = cmd.ExecuteScalar();
con.Close();
return a;
}
ASKER
Not really what I was looking for..Guess should close this thread
http://www.codepal.co.uk/show/How_to_DataBind_a_custom_class_object_to_a_GridView