I know that UltraWebGrid in version 11.1 is not ideal but I have to work with it at the moment. I would like to display data is hierarchical format. Could someone tell me what I am doing wrong? Is it possible to use DataSet with DataRelation as data source?
When I run code below I only get parent records.
<igtbl:UltraWebGrid ID="UltraWebGrid1" runat="server" > </igtbl:UltraWebGrid>
protected void Page_Load(object sender, EventArgs e) { DataSet ds1 = new DataSet(); DataSet ds2 = new DataSet();
DataTable ds1Table = ds1.Tables.Add("Author"); DataTable ds2Table = ds2.Tables.Add("Book"); ds1Table.Columns.Add("author_id", typeof(int)); ds1Table.Columns.Add("author", typeof(string)); ds2Table.Columns.Add("id", typeof(int)); ds2Table.Columns.Add("author_id", typeof(int)); ds2Table.Columns.Add("book", typeof(string));
DataRow r1 = ds1Table.NewRow(); r1["author_id"] = 1; r1["author"] = "Conan Doyle"; ds1Table.Rows.Add(r1);
DataRow r2 = ds1Table.NewRow(); r2["author_id"] = 2; r2["author"] = "Collins"; ds1Table.Rows.Add(r2);
DataRow rc1 = ds2Table.NewRow(); rc1["id"] = 1; rc1["author_id"] = 1; rc1["book"] = "The adventures of Sherlock Holmes"; ds2Table.Rows.Add(rc1);
DataRow rc2 = ds2Table.NewRow(); rc2["id"] = 2; rc1["author_id"] = 1; rc2["book"] = "The return of Sherlock Holmes"; ds2Table.Rows.Add(rc2);
ds1.Merge(ds2); DataRelation dr = new DataRelation("authorsAndBooks", ds1.Tables["Author"].Columns["author_id"], ds1.Tables["Book"].Columns["author_id"], false);
ds1.Relations.Add(dr);
UltraWebGrid1.DataSource = ds1; UltraWebGrid1.DataBind();
}
Thank you
Hello witepo,
In this scenario I would suggest ensuring that the grid has its ViewType property under DisplayLayout set as Hierarchical:
http://help.infragistics.com/Help/NetAdvantage/ASPNET/2011.1/CLR4.0/html/WebGrid_Display_Hierarchical_Data.html
I am attaching a hierarchical UltrawebGrid sample bound to a DataSet for your reference.
Please note that the UltraWebGrid control is now outdated and as of .NetAdvantage 2011 Volume 2 is no longer included in our product package. I would suggest that you consider switching to the WebDataGrid/WebHieararchicalDataGrid. More information regarding these controls is available at:
http://help.infragistics.com/NetAdvantage/ASPNET/2011.2/CLR4.0/?page=Web_WebDataGrid_WebDataGrid.html
Additional samples demonstrating the features of these grids can be found at: http://samples.infragistics.com/aspnet/
Hope this helps. Please do not hesitate to contact me if you have any question.