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

Updating Radtreeview data with Datasource

3 Answers 217 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
matt
Top achievements
Rank 1
matt asked on 05 Aug 2011, 03:17 PM
Hi,

I am looking for some help as I am new to this control.

I have set up a RadTreeView to pull data from an Oracle database via the Datasources option. I have been able to load 3 levels of data. Now, I want to be able to edit the data on the treeview and that update be replicated back to the oracle database.

Thus far I have come up with the following. However I think I am missing something.

When I update a Node, the data is saved back to the database but the child nodes on the treeview dissapear (since the parent has now changed). I cannot find a way of refreshing the treeeview. Can somebody please help??

 

Private Sub RadTreeView1_Edited(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.TreeNodeEditedEventArgs) Handles RadTreeView1.Edited

 

 

On Error GoTo ErrMsg

 

 

Dim DBConnection As New OleDbConnection("Provider=msdaora;Data Source=ubrmos01;User Id=tiadmin;Password=******")

 

 

Dim strsql As String

 

 

If e.Node.Level = 0 Then

 

DBConnection.Open()

strsql =

"UPDATE APPLICATION set APPLICATION = " & "'" & e.Node.Text & "'" & " where APPLICATION = " & "'" & Text_beforeedit & "'"

 

 

Dim Command As New OleDbCommand(strsql, DBConnection)

 

Command.ExecuteNonQuery()

 

End If

 

 

If e.Node.Level = 1 Then

 

DBConnection.Open()

strsql =

"UPDATE ENVIRONMENT set ENVIRONMENT = " & "'" & e.Node.Text & "'" & " where ENVIRONMENT = " & "'" & Text_beforeedit & "'"

 

 

Dim Command As New OleDbCommand(strsql, DBConnection)

 

Command.ExecuteNonQuery()

 

End If

 

 

Exit Sub

 

errmsg:

e.Node.Text = Text_beforeedit

MsgBox(Err.Description, MsgBoxStyle.Critical,

"Error Updating Database")

 

 

End Sub

 

3 Answers, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 10 Aug 2011, 03:58 PM
Hi Matt,

Thank you for contacting us.

If you are saving the changes using SQL Update queries, you should refresh the data source referenced by the RadTreeView. You can do that by fetching a fresh copy from your data base. Nevertheless, I have enclosed a better approach that uses ADO.NET Table adapters.

Kind regards,
Svett
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
matt
Top achievements
Rank 1
answered on 10 Aug 2011, 04:06 PM
Thanks.

I am unable to open the file. I am using Visual Studio 2008; can you save a compatible version?
0
Svett
Telerik team
answered on 12 Aug 2011, 10:27 AM
Hi Matt,

I am enclosing the Visual Studio 2008 version of the project.

Kind regards,
Svett
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
Treeview
Asked by
matt
Top achievements
Rank 1
Answers by
Svett
Telerik team
matt
Top achievements
Rank 1
Share this question
or