Problem Description - I have three tables in the database ?
? Functions
? Sub-Functions
? Test Cases
Each function has specific sub-functions and subsequently each sub-function have a number of test cases. Now, I have to let the user select which test
cases he/she wants to select before going on to carry on other tasks with them. They way I have to represent them have been portrayed in the following picture -
http://pg.photos.yahoo.com/ph/naughty_boy05/detail?.dir=/1186&.dnm=2380.jpg&.src=ph I would be having two sections on my page. The first section will initially display all the available functions. If a user clicks on a function, he can
further see the sub-functions underneath it and subsequently its test-cases. Each function/sub-function/test-case has a check box adjacent
to them. If the user checks it, and then hits the ?R? button in the middle of the two sections, then all the checked functions/sub-functions/test-cases should be moved over to the ?Section B?. The user will also have the flexibility to remove any function/sub-function/test-case from ?Section B? back to ?Section A? by using the linkbutton ?L?.
*****************************************************************************
Now, I could think of two ways of doing it (a) Using TreeView (b) Using Panels.
Since TreeView sounds best for it, I have started playing with it. I can create TreeViews from my db using code behind. Also, using the code given in -
http://forums.asp.net/301440/ShowPost.aspx I am able to check the parent checkboxes if all the child nodes are checked and so on. Now, I have added a web form button and on its click I want to find out all the checkboxes that have been checked so that I can place them on a new treeview for Sectoin B. Just to experiment, I wrote the follwoing fuction which I am calling on Button Click:
private
void GetCheckedValues(TreeNodeCollection myNodes) //myNodes is basically TreeView1.Nodes
{
foreach(TreeNode i in myNodes)
{
if(i.Type == "folder") //While creating the nodes, I have made all 1st level nodes as folders and the second level nodes as files.
{ GetCheckedValues(i.Nodes); }
else
{
if(i.Checked)
lblChecked.InnerText += i.Text.ToString(); // Simply placing their text into a label
}
}
}
To my astonishment, all the nodes in this show up as Checked="false" and hence the lblChecked label turns out to be empty.
It would be great if someone can tell me why is all the value coming as unchecked in the post back / code behind. Also, is treeview the best approach for this problem or using panels would have been a better idea.
Since I am a novice to ASP.NET, any input will be really appreciated.