Dear All;
I am using v 10.3 , I have to tables ( Owners and cars )
I want to display all the cars for each owner as the following :
Owner1---Address1
car1
car2
car3
Owner2 -----Address2
I want to use the Bands< shell I use defferent dataset to bind for band and other dataset to bind for the bandchild or make a loop while the sqldatareader to read the data and create the rows dynamically ???
kindly some links or code samples or tips will appreciated.
regards...
Hi,
In order to display this in the grid, you need a single DataSource that contains all of the data. You cannot bind the grid to two different data sources.
It seems like this should be pretty easy to do. If you have two tables, all you need to do is create a DataSet that contains both tables and create a Relationship between them.
If you cannot do that, then an alternative would be to use the UltraDataSource to create the structure and load it on-demand from wherever you want. There is a sample of using the Load-On-Demand functionality installed with NetAdvantage (assuming you chose to install the samples). It's in the WinGrid Samples explorer and it's called "Virtual Mode".
Thanks for your reply< It works fine after I add the following :
query = "SELECT onwerusername,ownername,ownermobile,owneremail,horseID,horsename,horsecolor,horseweight,ownerID FROM owner INNER JOIN Horse ON owner.onwerusername=Horse.ownerID ";
SqlConnection conn = new SqlConnection();
conn.ConnectionString = connStr;
cmd = new SqlCommand(query,conn);
conn.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
DataRow Row = dataTable1.NewRow();
Row["OwnerID"] = dr[0].ToString();
Row["Owner Name"] = dr[1].ToString();
Row["Owner Mobile"] =dr[2].ToString();
Row["Owner Email"] = dr[3].ToString();
dataTable1.Rows.Add(Row);
Row = dataTable2.NewRow();
Row["HorseID"] = dr[4].ToString();
Row["Horse Name"] = dr[5].ToString();
Row["Horse Color"] = dr[6].ToString();
Row["Horse Wieght"] = dr[7].ToString();
Row["Owner ID"] = dr[8].ToString();
dataTable2.Rows.Add(Row);
}
DataRelation relation = new DataRelation("Relationship", dataSet1.Tables[dataTable1.TableName].Columns["OwnerID"], dataSet1.Tables[dataTable2.TableName].Columns["Owner ID"],false);
dataSet1.Relations.Add(relation);
this.ultraGrid1.DataSource = this.dataSet1;
But the problem is the Parent Rows are duplicated coz I add false to the relation, So what to do in that case???