Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
580
UlrtawWebGrid v11.1 – how to display data as hierarchical grid?
posted

 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 

Parents Reply Children
No Data