It has the value but don't know why still throwing nullRefrenceException.
This is my code for treeView with ChildView.
I want to make a treeView with parent and child from DataSet.
Code:
adp3 = new SqlDataAdapter("select country.CountryId  , country.CountryName ,` city.CityId , city.CityName "+
                          " from Country as country join City as city on city.CountryId = country.CountryId order by cityid ", Program.con);
adp3.Fill(ds,"bb");
this.mtree.Nodes.Clear();
string mdt = "";
string mref = "";
string mtitle = "";
foreach (DataRow row in ds.Tables["bb"].Rows)
{
    if (!row["Countryname"].ToString().Equals(mdt.Trim()))
    {
        TreeNode node = new TreeNode();
        node.Name = (string)row["CountryId"].ToString().Trim();
        node.Text = row["CountryName"].ToString();
        this.mtree.Nodes.Add(node);
        mdt = row["CountryName"].ToString().Trim();
        mtitle = "";
    }
    else if (!row["CityName"].ToString().Equals(mtitle.Trim()))
    {
        TreeNode node2 = new TreeNode();
        node2.Name = (string)row["CityId"].ToString().Trim();
        node2.Text = row["CityName"].ToString().Trim();
        this.mtree.Nodes[mdt.Trim()].Nodes.Add(node2);
        mtitle = row["CityName"].ToString().Trim();
    }
}

 
     
    