Click here to Skip to main content
16,020,188 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
Im working on treeview in which I am trying to retrieve already checked checkboxes of treeview when user updates the form again.
I have tried a lot.I have tried to retrieve the database data and compared to treeview data but no use.I need this thing.Please,help me to find this solution.
Thanks all,



C#
StringBuilder sbSQLCompany = new StringBuilder();
sbSQLCompany.Append("Select HouseFeatureID,HouseName,Features from tblHouseFeatureP");
//SqlConnection conn = new SqlConnection();
//conn.ConnectionString = ConfigurationManager.ConnectionStrings["BuckshawHomesConnectionString"].ToString();
try
{
  using (SqlConnection cn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["BuckshawHomesConnectionString"].ConnectionString))
  {
     using (SqlCommand cm1 = new SqlCommand(sbSQLCompany.ToString(), cn1))
  {
  //cm1.Parameters.AddWithValue("@HouseFeatureID",  Membership.GetUser().ProviderUserKey.ToString());
  cn1.Open();
  using (SqlDataReader rd = cm1.ExecuteReader(CommandBehavior.CloseConnection))
  {
    while (rd.Read())
    {
      string s = rd["Features"].ToString();
      foreach (TreeNode Node in TreeView1.Nodes[0].ChildNodes)
      {
        if(rd["HouseName"].ToString()==tbPropertyName.Text)
        {
          if (Node.Depth == 1)
          {
            if (Node.Text == rd["Features"].ToString())
            {
              Node.Checked = true;
            }
            else
            {
              Node.Checked = false;
            }
          }
        }
      }
    }
  }
}
catch
{

}
Posted
Updated 25-Jun-14 10:11am
v2
Comments
dan!sh 19-May-14 5:46am    
Please share more details. What do you mean by updates the form again? Also, share some relevant code.
MayurDighe 19-May-14 5:49am    
Share more details about your problem...

if possible, post the Code where you get Stuck...

Happy Programming...:-)
Sunasara Imdadhusen 19-May-14 6:11am    
Can you please provide your code, so we can see what happening
ZurdoDev 19-May-14 16:52pm    
Where are you stuck?
[no name] 20-May-14 1:55am    
Hi all,
This is my code...
StringBuilder sbSQLCompany = new StringBuilder();
sbSQLCompany.Append("Select HouseFeatureID,HouseName,Features from tblHouseFeatureP");
//SqlConnection conn = new SqlConnection();
//conn.ConnectionString = ConfigurationManager.ConnectionStrings["BuckshawHomesConnectionString"].ToString();
try
{
using (SqlConnection cn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["BuckshawHomesConnectionString"].ConnectionString))
{
using (SqlCommand cm1 = new SqlCommand(sbSQLCompany.ToString(), cn1))
{
//cm1.Parameters.AddWithValue("@HouseFeatureID", Membership.GetUser().ProviderUserKey.ToString());
cn1.Open();
using (SqlDataReader rd = cm1.ExecuteReader(CommandBehavior.CloseConnection))
{
while (rd.Read())
{
string s = rd["Features"].ToString();
foreach (TreeNode Node in TreeView1.Nodes[0].ChildNodes)
{
if(rd["HouseName"].ToString()==tbPropertyName.Text)
{
//if(tbPropertyName.Text==rd["HouseName"].ToString())
//{
//string s = rd["Features"].ToString();
if (Node.Depth == 1)
{
if (Node.Text == rd["Features"].ToString())
{
//if (Node.Value == rd["HouseFeatureID"].ToString())
//{
//Node.Checked = true;
Node.Checked = true;

}
else
{

Node.Checked = false;

}
}

}
}
}
}
}
}
}
//}
catch
{



}
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900