Binding Treeview while clicking Combobox

5 posts, 0 answers
  1. balaji
    balaji avatar
    69 posts
    Member since:
    May 2009

    Posted 02 Jun 2009 Link to this post

    Hi Folks
    I would like to knw how to bind the Rad Tree view while clicking combo box.
    Means on selected change Event..

    Thanks
    Regards
    N.Balaji
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Jun 2009 Link to this post

    Hello Balaji,

    Checkout the online demo which demonstrates how to bind the RadTreeView from code behind. You can also refer following links for more information on this. Hope this helps.
    Data Binding Overview
    Binding to DataTable, DataSet or DataView
    Binding to Hierarchical Data

    Thanks,
    Shinu.
  3. balaji
    balaji avatar
    69 posts
    Member since:
    May 2009

    Posted 03 Jun 2009 Link to this post

    Sorry Shinu
    It didnt work out.
    Please Help me i need to sort out this probs

    Actually i have a separate combo box which contains some values.
    If i select the comboboxvalue  i shuld bind the treeview using ajax.
    I was doing this before using auto post back property.


     protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
        {
            sourceconnectionstring = "Data Source=" + DropDownList1.Text.ToString() + ";Initial Catalog=" + DropDownList3.Text + ";";
            if (RadioButtonList2.SelectedItem.Text == "Windows")
            {
                sourceconnectionstring += "Integrated Security=SSPI";

            }
            else
            {
                TextBox3.Text = ViewState["pwd1"].ToString();
                sourceconnectionstring += "User ID=" + TextBox5.Text + ";Password=" + TextBox3.Text + "";

            }


            try
            {
                sourcedbqry = "SELECT name as tblname FROM sys.Tables";
                dbdt = new DataTable();
                dbdt = dt.fetchvalues(sourceconnectionstring, sourcedbqry);
                if (dbdt.Rows.Count > 0)
                {
                    bindsourcetree(dbdt, sourceconnectionstring);
                }
                treeview1.Visible = true;


            }
            catch (Exception ex)
            {
                Util.LogException(ex);
            }

        }

     private void bindsourcetree(DataTable dts, string connections)
        {

            try
            {
                RadTreeNode radnodetbl = new RadTreeNode();

                for (int i = 0; i < dts.Rows.Count; i++)
                {
                    radnodetbl = new RadTreeNode();
                    radnodetbl.Text = dts.Rows[i][0].ToString();
                    radnodetbl.ImageUrl = "Images/tbl.jpg";
                    dt1 = new DataTable();
                    dt1 = dt.fetchvalues(connections, "select a.name from sys.columns a INNER JOIN sys.objects b ON a.object_id=b.object_id and b.name='" + dts.Rows[i][0].ToString() + "'");
                    if (dt1.Rows.Count > 0)
                    {
                        for (int j = 0; j < dt1.Rows.Count; j++)
                        {
                            RadTreeNode radcols = new RadTreeNode();
                            radcols.Text = dt1.Rows[j][0].ToString();
                            radcols.ImageUrl = "Images/columns.jpg";
                            radnodetbl.Nodes.Add(radcols);
                        }


                    }

                    RadTreeView1.Nodes.Add(radnodetbl);
                }
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
            }
        }


    am gettin gthe outpout as






  4. balaji
    balaji avatar
    69 posts
    Member since:
    May 2009

    Posted 03 Jun 2009 Link to this post

    Sorry Shinu
    It didnt work out.
    Please Help me i need to sort out this probs

    Actually i have a separate combo box which contains some values.
    If i select the comboboxvalue  i shuld bind the treeview using ajax.
    I was doing this before using auto post back property.


     protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
        {
            sourceconnectionstring = "Data Source=" + DropDownList1.Text.ToString() + ";Initial Catalog=" + DropDownList3.Text + ";";
            if (RadioButtonList2.SelectedItem.Text == "Windows")
            {
                sourceconnectionstring += "Integrated Security=SSPI";

            }
            else
            {
                TextBox3.Text = ViewState["pwd1"].ToString();
                sourceconnectionstring += "User ID=" + TextBox5.Text + ";Password=" + TextBox3.Text + "";

            }


            try
            {
                sourcedbqry = "SELECT name as tblname FROM sys.Tables";
                dbdt = new DataTable();
                dbdt = dt.fetchvalues(sourceconnectionstring, sourcedbqry);
                if (dbdt.Rows.Count > 0)
                {
                    bindsourcetree(dbdt, sourceconnectionstring);
                }
                treeview1.Visible = true;


            }
            catch (Exception ex)
            {
                Util.LogException(ex);
            }

        }

     private void bindsourcetree(DataTable dts, string connections)
        {

            try
            {
                RadTreeNode radnodetbl = new RadTreeNode();

                for (int i = 0; i < dts.Rows.Count; i++)
                {
                    radnodetbl = new RadTreeNode();
                    radnodetbl.Text = dts.Rows[i][0].ToString();
                    radnodetbl.ImageUrl = "Images/tbl.jpg";
                    dt1 = new DataTable();
                    dt1 = dt.fetchvalues(connections, "select a.name from sys.columns a INNER JOIN sys.objects b ON a.object_id=b.object_id and b.name='" + dts.Rows[i][0].ToString() + "'");
                    if (dt1.Rows.Count > 0)
                    {
                        for (int j = 0; j < dt1.Rows.Count; j++)
                        {
                            RadTreeNode radcols = new RadTreeNode();
                            radcols.Text = dt1.Rows[j][0].ToString();
                            radcols.ImageUrl = "Images/columns.jpg";
                            radnodetbl.Nodes.Add(radcols);
                        }


                    }

                    RadTreeView1.Nodes.Add(radnodetbl);
                }
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
            }
        }


    am gettin gthe outpout as






  5. balaji
    balaji avatar
    69 posts
    Member since:
    May 2009

    Posted 03 Jun 2009 Link to this post

    c
Back to Top