Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am building the treeview based on xml and i will selecte the nodes by through the checkboxes in treeview. Now when i click the submit button, in next page i am binding the values in gridview which i selected the treeview nodes in privious page. I request please help me on this.

Thanks
Mahesh.
Posted
Comments
demouser743 1-Sep-10 0:44am    
If you have written any code please post so that we can help you

1 solution

Here is how you should be able to do it.

(I created the example assuming you need to show some selected Person objects in the GridView). You just need to change the following code according to your need:

C#
/// <summary>
/// Load the selected persons in the GridView
/// </summary>
private void LoadPersons()
{
       List<Person> persons = new List<Person>();
       foreach (TreeNode node in TreeView1.CheckedNodes)
       {
           string Value = node.Value; //Value could be an Id of the data
           int Id = Convert.ToInt32(Value);
           string Text = node.Text; //Text is displayed as the node value
           string path = node.ValuePath; // Path of the node from the Root Node
           Person person = GetPersonById(Id);
           if (person != null)
           {
               persons.Add(person);
           }
       }
       GridView1.DataSource = persons;
       GridView1.DataBind();
}
 
Share this answer
 

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