Is there an easy way to return all the times in the treeview in one statement? I have a treeview that I manually load through code that is 5-6 levels deep with checkboxes. I then need to go through every item in the Treeview and check if it is checked or not and update the database. It doesn't matter what order it goes in. Right now, i am looping through each level then looping through the children and it is very slow. Is there a more efficient way of looping through all items and getting the checkstate?
foreach (RadTreeViewItem item in treeColumns.Items)
{
DataAccess.ctx.ExecuteCommand("Update WorkFlow Set SortOrder=" + lOrder.ToString() + " Where ItemID='" + new Guid(item.Tag.ToString()) + "'");
RecursiveItems(item);
lOrder++;
}
private
void RecursiveItems(RadTreeViewItem treeitem)
{
int lOrder = 1;
foreach (RadTreeViewItem item in treeitem.Items)
{
DataAccess.ctx.ExecuteCommand("Update WorkFlow Set SortOrder=" + lOrder.ToString() + " Where ItemID='" + new Guid(item.Tag.ToString()) + "'");
if (item.Items.Count > 0)
{
RecursiveItems(item);
}
lOrder++;
}
DataAccess.ctx.SubmitChanges();
}