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

How to delete a node form selfreferenced databinded radTree view

3 Answers 74 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Anoop
Top achievements
Rank 1
Anoop asked on 28 Dec 2012, 07:49 PM
I am using sql server database.
1. It is a self referencing database created as per Binding to Self Referencing Data in help document
2.Table definition is given below.
CREATE TABLE [dbo].[Node] (
[ID] INT IDENTITY (1, 1) NOT NULL,
[ParentID] INT NULL,
[Name] TEXT NULL,
[Note] TEXT NULL,
PRIMARY KEY CLUSTERED ([ID] ASC)
);

3.code binded as folws
this.radTreeView1.DisplayMember = "Name";
this.radTreeView1.ParentMember = "ParentID";
this.radTreeView1.ChildMember = "ID";
this.radTreeView1.ValueMember = "ID";
radTreeView2.TreeViewElement.EditMode =TreeNodeEditMode.Text;

4.I had deleted a node and updated database using tableadpter method.But if the node have child nodes those data will not be removed from original database.So how delete nodes +child nodes and update database ?

3 Answers, 1 is accepted

Sort by
0
Ivan Todorov
Telerik team
answered on 03 Jan 2013, 08:47 AM
Hello Anoop,

Thank you for contacting us.

To achieve this, you need to add a foreign key constraint with a cascade delete rule in your DataSet designer in VisualStudio. I have attached a screenshot which demonstrates how it should be set.

I hope this will help you. If you need further help, do not hesitate to write back.

Regards,
Ivan Todorov
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Anoop
Top achievements
Rank 1
answered on 03 Jan 2013, 01:40 PM
thanks it's working but i found some errors
this.appointmentsTableAdapter.Fill(this.dataBaseDataSet.Appointments);
this returns Cannot clear table Notes because ForeignKeyConstraint FK_Notes_Notes enforces constraints and there are child rows in Notes.
also error occurs when deleting the last root node or if a single root node is present in table.
0
Ivan Todorov
Telerik team
answered on 08 Jan 2013, 09:24 AM
Hello Anoop,

You might receive this error if you have a constrain in the SQL database. I am attaching a sample project along with a database backup which demonstrates how this could be implemented. Note that there are no constraints or relation in the SQL database but there is a relation in the DataSet designer in Visual Studio.

I hope you find this useful. Feel free to ask if you have any other questions.

All the best,
Ivan Todorov
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
Tags
Treeview
Asked by
Anoop
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
Anoop
Top achievements
Rank 1
Share this question
or