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 i have also same kind of hierarchical data need to show in ultrawingrid but i have 4 hierarchical label not only two.
even if i can get 4 hierarchical structure into list of classes but problem is that i have 10 years data need to display in PIVOT format.
ex: jan 16, feb 16, mar 16 like for 10 years(120 columns)
i have below things need to achieve
1)how can i show data in grid for 10 years(is there any option we can PIVOT the columns)
2) even if i can get the data in PIVOT as above(in hierarchical structure) and how can generate this 10 years columns dynamically
3) after creating columns i want to bind bands based on parent band selection(don't want to bind all hierarchical structure in page load) its very slow
means based on selection of band 0 header, band 1 will bind based on band 0 ID.(dynamically want to bind each child bands based on parent band)
same we do in nested grid in asp.net .
its really urgent..
Thanks
Thank your for your reply : acctually I recognize that while I am extracting the information from the database while applying the inner Join query the same owner who have more then one horse is appearing more then one time , so what I have down , I store all the owners in datatable and by defferrent query I store all the horses , then I make datatable relation : as the following :
public void FillDatGrid()
{
Fillownertable();
Fillhorsetable();
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;
}
// Fill datatable of owners
public void Fillownertable()
SqlCommand cmd = null;
// TODO: This line of code loads data into the 'qn_archiveDataSet1.roles' table. You can move, or remove it, as needed.
// this.rolesTableAdapter.Fill(this.qn_archiveDataSet1.roles);
functions fn = new functions();
string connStr = fn.Getconn();
string query = "";
query = "SELECT onwerusername,ownername,ownermobile,owneremail FROM owner ";
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);
public void Fillhorsetable()
query = "SELECT horseID,horsename,horsecolor,horseweight,ownerID FROM Horse ";
DataRow Row = dataTable2.NewRow();
Row["HorseID"] = dr[0].ToString();
Row["Horse Name"] = dr[1].ToString();
Row["Horse Color"] = dr[2].ToString();
Row["Horse Wieght"] = dr[3].ToString();
Row["Owner ID"] = dr[4].ToString();
dataTable2.Rows.Add(Row);
best Regards and thank for your support>
Hello Wolvesworld,
At a first look everything is correct in your code and I try to reproduce your issue in a small sample, but without success. Could you please take a look at the code below and attached sample (UltraGridWithTablesRelationsSQLSelect).
namespace UltraGridWithTablesRelationsSQLSelect { public partial class Form1 : Form { private DataSet ds; private DataTable dtParent; private DataTable dtChild; public Form1() { InitializeComponent(); ds = new DataSet(); dtParent = new DataTable("Parent"); dtChild = new DataTable("Child"); dtParent.Columns.Add("ID",typeof(int)); dtParent.Columns.Add("sItem",typeof(string)); dtChild.Columns.Add("ID",typeof(int)); dtChild.Columns.Add("sDescription",typeof(string)); dtChild.Columns.Add("sNote",typeof(string)); ds.Tables.Add(dtParent); ds.Tables.Add(dtChild); DataRelation relation = new DataRelation("Relationship", dtParent.Columns["ID"], dtChild.Columns["ID"], false); ds.Relations.Add(relation); this.ultraGrid1.DataSource = this.ds.Tables["Parent"]; } private void Form1_Load(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Data Source=IGBGSOFDS22;Initial Catalog=Test;Integrated Security=True"; SqlCommand cmd = new SqlCommand("select * from [dbItems] inner join [dbRows] ON [dbItems].ID =[dbRows].ID", conn); conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { dtParent.Rows.Add(dr[0], dr[1]); dtChild.Rows.Add(dr[2], dr[3], dr[4]); } } } }
namespace UltraGridWithTablesRelationsSQLSelect
public partial class Form1 : Form
private DataSet ds;
private DataTable dtParent;
private DataTable dtChild;
public Form1()
InitializeComponent();
ds = new DataSet();
dtParent = new DataTable("Parent");
dtChild = new DataTable("Child");
dtParent.Columns.Add("ID",typeof(int));
dtParent.Columns.Add("sItem",typeof(string));
dtChild.Columns.Add("ID",typeof(int));
dtChild.Columns.Add("sDescription",typeof(string));
dtChild.Columns.Add("sNote",typeof(string));
ds.Tables.Add(dtParent);
ds.Tables.Add(dtChild);
DataRelation relation = new DataRelation("Relationship", dtParent.Columns["ID"], dtChild.Columns["ID"], false);
ds.Relations.Add(relation);
this.ultraGrid1.DataSource = this.ds.Tables["Parent"];
private void Form1_Load(object sender, EventArgs e)
conn.ConnectionString = "Data Source=IGBGSOFDS22;Initial Catalog=Test;Integrated Security=True";
SqlCommand cmd = new SqlCommand("select * from [dbItems] inner join [dbRows] ON [dbItems].ID =[dbRows].ID", conn);
dtParent.Rows.Add(dr[0], dr[1]);
dtChild.Rows.Add(dr[2], dr[3], dr[4]);
Please if you have any questions, do not hesitate to ask. Also I attached two additional samples and if you have time, you could take a look at them.
Regards
Additional samples:
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 ";
cmd = new SqlCommand(query,conn);
Row["Owner Mobile"] =dr[2].ToString();
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();
But the problem is the Parent Rows are duplicated coz I add false to the relation, So what to do in that case???
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".