This is a migrated thread and some comments may be shown as answers.

Where can I find sample code for displaying FAQs using RadTreeView ?

1 Answer 61 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
gs1711
Top achievements
Rank 1
gs1711 asked on 15 Dec 2010, 02:30 PM
In my table I have columns named Ques, Answer, ID, etc. If I want to display these question answers on my page using RadTreeView, how do I implement this ? Like I want the parent node in the TreeView to be the question and child node should be the answer. Any sample code for that in here ?

1 Answer, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 20 Dec 2010, 12:44 PM
Hello gs1711,

You can not directly bind the table to treeView. You need to change the relation a little bit. For example you can create a table with the following structure:
  - Column: Id (primary key, int);
  - Column: ParentId (foreign key pointing to the Id of the same table, int, but nullable - the root nodes need to have null for this column);
  - Column: Text (varChar(x), the text that the node should display - i.e. question or answer).

Then having this table you can bind it to the TreeView as follows:
treeView.DataTextField = "Text";         
treeView.DataFieldID = "Id";
treeView.DataParentID = "ParentId";
treeView.DataSource = dataTable;           
treeView.DataBind();


Regards,
Nikolay Tsenkov
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
General Discussions
Asked by
gs1711
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Share this question
or