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
364
Binding an UltraWebTree to an ODBC Dataset
posted

I am trying to create webtree that will display a list of companies, broken down by their first character (alphabet list which opens to show all companies starting with that letter).  But I can't seem to get it working.  I am using MySQL as my database.

I am having some trouble to get my webtree to display on the screen.  Only my WebPanel shows up, with a blank area where the webtree should be.  The code seems to run without errors and when I walk through the code I can check the results of my datasets and they are returning the correct data.  I am attaching the source code for my page along with a screen shot of the resulting screen (added borders to show where tree should show up, lower left below webpanel).

******************************************************************************************************************

using System;

using System.Data;

using System.Configuration;

using System.Data.Odbc;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

namespace MSAResearcher

{

/// <summary>

/// Summary description for WebForm1.

/// </summary>

public partial class TreeDataBinding : System.Web.UI.Page

{

protected void Page_Load(object sender, System.EventArgs e)

{

//WebPanel1.Visible = WebSamplesCS.Config.ShowDescription;

// Put user code to initialize the page here

if (!this.IsPostBack)

{

// Get Database connection path for MSA db

string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["MSAConnection"].ToString();

OdbcConnection myConnection = new OdbcConnection(connectionString);

try

{

myConnection.Open();

}

catch

{

}

DataSet treeview =
new DataSet("treeview");

OdbcDataAdapter cmdAlpha = new OdbcDataAdapter("Select distinct LEFT(Name, 1) AS CompAlpha FROM Company ORDER BY CompAlpha", myConnection);

OdbcDataAdapter cmdCompany = new OdbcDataAdapter("Select LEFT(Name, 1) AS CompAlpha, Code, Name, Status FROM Company ORDER BY CompAlpha, Name", myConnection);

//OdbcDataAdapter cmdActions = new OdbcDataAdapter("Select * From tbl_Units, tbl_Assets where tbl_Units.unAssetsID = tbl_Assets.asUniqueNum", myConnection);

cmdAlpha.Fill(treeview, "tbl_Alpha");

cmdCompany.Fill(treeview, "tbl_Company");

//cmdActions.Fill(treeview, "tbl_Actions");

treeview.Relations.Add("Alpha", treeview.Tables["tbl_Alpha"].Columns["CompAlpha"], treeview.Tables["tbl_Company"].Columns["CompAlpha"]);

//treeview.Relations.Add("Companies", treeview.Tables["tbl_Company"].Columns["asUniqueNum"], treeview.Tables["tbl_Units"].Columns["unAssetsID"]);

this.wtCompanyList.DataSource = treeview.Tables["tbl_Alpha"].DefaultView;

this.wtCompanyList.Levels[0].RelationName = "Alpha";

this.wtCompanyList.Levels[0].ColumnName = "CompAlpha";

//this.wtCompanyList.Levels[1].RelationName = "Assets";

this.wtCompanyList.Levels[1].ColumnName = "Name";

//this.wtCompanyList.Levels[2].ColumnName = "unName";

this.wtCompanyList.Visible = true;

}

}

#region Web Form Designer generated codeoverride protected void OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeComponent();

base.OnInit(e);

}

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

}

#endregion

}

}

******************************************************************************************************************

 I appreciate any help you can give me.

WebTreeODBC.zip