I think you make a simple mistake. You need to find Child Nodes so your loop must be go through the "tn.ChildNodes". see below code block...
Your code:
if (tn.ChildNodes.Count > 0)
{
foreach (TreeNode Ctn in TreeView1.Nodes)
{
SqlCommand com = new SqlCommand("Delete From Role_Menu Where Menu_id=" + strTreeValue, con);
com.ExecuteNonQuery();
}
}
Change Code:
if (tn.ChildNodes.Count > 0)
{
foreach (TreeNode Ctn in tn.ChildNodes)
{
SqlCommand com = new SqlCommand("Delete From Role_Menu Where Menu_id=" + strTreeValue, con);
com.ExecuteNonQuery();
}
}
Try this maybe it's help you.