Radtreeview selectednode value

3 posts, 0 answers
  1. Nagendra
    Nagendra avatar
    35 posts
    Member since:
    Jan 2011

    Posted 16 Mar 2011 Link to this post

    Hi,

    I have one Radtreeview in the left side and Radgrid in the rightside.
    Radtreeview binded dynamically. Its working fine.
    private void BuildDataTable()
        {
            DataTable data = new DataTable();
            data.Columns.Add("parent_id");
            data.Columns.Add("child_id");
            data.Columns.Add("child_code");

            data.Rows.Add(null, "25", "AF-Angel Falls");
            data.Rows.Add(null, "26", "RR-Rapid Run");
            data.Rows.Add("25", "38", "P1-Phase1");
            data.Rows.Add("26", "39", "P1-Phase1");
            data.Rows.Add("38", "172", "001-Lot1");
            data.Rows.Add("38", "173", "002-Lot2");
            data.Rows.Add("38", "174", "003-Lot3");
            data.Rows.Add("38", "175", "004-Lot4");
            data.Rows.Add("38", "176", "005-Lot5");
            data.Rows.Add("39", "177", "001-Lot1");
            data.Rows.Add("39", "178", "002-Lot2");
            data.Rows.Add("39", "179", "003-Lot3");
            data.Rows.Add("39", "180", "004-Lot4");
            data.Rows.Add("39", "181", "005-Lot5");

            RadTreeView1.DataFieldID = "child_id";
            RadTreeView1.DataFieldParentID = "parent_id";
            RadTreeView1.DataTextField = "child_code";
            RadTreeView1.DataValueField = "child_id";
            RadTreeView1.ExpandAnimation.Duration = 100;
            RadTreeView1.DataSource = data;
            RadTreeView1.DataBind();
        }

    when i select childnode (Lot1), based on childnode value i have to populate radgrid in the rightside.

    private void BindRadGrid()
        {
           string selectedNodevalue = RadTreeView1.SelectedNode.Value; // Get the selected node value (ID)

            // Set the grid DataSource
            conn = new MySqlConnection(connString);
            MySqlDataAdapter adapter = new MySqlDataAdapter();
            string query = "SELECT distinct tsa.org_finish_Date,mjt.jobtype_code,tsap.total_float,tsap.activity_desc,tsap.original_duration, " +
                    "tsap.early_start_display,tsap.early_finish_display, tsap.actual_start,tsap.actual_finish,tsap.pct,mdrc.delay_reason_code_id, " +
                    "mdrc.delay_reason_code,tsap.delay_days,tsap.act_log,tsap.rem_duration, tsap.mandatory_start,tsap.mandatory_finish " +
                    "from tsm_schedule_activities_publish_s tsap " +
                    "inner join tsm_schedule ts on tsap.schedule_id=ts.schedule_id " +
                    "inner join tsm_schedule_activities tsa on tsap.schedule_id=tsa.schedule_id " +
                    "inner join msm_delay_reason_codes mdrc on tsap.delay_reason_code_id=mdrc.delay_reason_code_id " +
                    "inner join msl_jobtypes mjt on ts.jobtype_id=mjt.jobtype_id " +
                    "inner join min_com_lots mcl on mcl.com_lot_id=ts.com_lot_id where mcl.lot_id="+selectedNodevalue;
            adapter.SelectCommand = new MySqlCommand(query, conn);
            // DataSet myDataSet = new DataSet();
            conn.Open();
            try
            {
                adapter.Fill(myDataSet, "tsm_schedule_activities_publish_s");
            }
            finally
            {
                conn.Close();
            }
            RadGrid1.DataSource = myDataSet;
            //RadGrid1.DataBind();
        }

      error is, "Object reference not set to an instance of an object".
    I am getting an error in this area
    string selectedNodevalue = RadTreeView1.SelectedNode.Value; // Get the selected node value (ID).

    my final output is in the attachment, when i hard coded the childnode value i got output like this.

    Thanks,
    Nagendra.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Mar 2011 Link to this post

    Hello Nagendra,

    Please check that you have added '!IsPostBack' condition in PageLoad when binding RadTreeView.

    C#:
    protected void Page_Load(object sender, EventArgs e)
      {
          if (!IsPostBack)
          {
              BuildDataTable();
          }
      }

    Thanks,
    Princy.
  3. Nagendra
    Nagendra avatar
    35 posts
    Member since:
    Jan 2011

    Posted 22 Mar 2011 Link to this post

    Hi Princy,

    Thanks for your reply, i resolved this issue.

    Thanks.
    Nagendra.
Back to Top