How to delete a node form selfreferenced databinded radTree view

4 posts, 0 answers
  1. Anoop
    Anoop avatar
    18 posts
    Member since:
    Dec 2012

    Posted 28 Dec 2012 Link to this post

    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 ?
  2. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 03 Jan 2013 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Anoop
    Anoop avatar
    18 posts
    Member since:
    Dec 2012

    Posted 03 Jan 2013 Link to this post

    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.
  5. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 08 Jan 2013 Link to this post

    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.
Back to Top