I have table and data as
Table1
Field1 Field2
0001 100
0001 200
0001 300
0002 001
0002 002
0003 003
How I can create treeview with vb 2008 sqlcommand by datareader as
Treeview
-0001
--100
--200
--300
-0002
--001
--002
--003
Thanks,
Teddy
9 Answers, 1 is accepted
Thank you for writing. Please take a look at our online documentation. RadTreeView provides binding to related data with the aid of data relations.
Also you can take a look at our Demo application. There you can see sample code for a RadTreeView bound to related data.
Regards,
Victor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Hi Victor ,
Thank you for your kind support but Could you please recommend on my code as below?
Sb =
New StringBuilder()
Sb.Remove(0, Sb.Length)
Sb.Append(
"SELECT * FROM TABLE")
Dim sqlShowData As String =Sb.ToString
With Command
.CommandType = CommandType.Text
.CommandText = sqlShowData
.Connection = Connnection
Dr = .ExecuteReader
If Dr.HasRows Then
Dt = New DataTable
Dt.Load(Dr)
rGrid.DataSource = Dt
Dr.Close()
End If
End With
Thanks
Thank you for writing. The code you provided binds RadGridView to a single data table. Please clarify whether you need to use RadGridView or RadTreeView with hierarchical data. If you need to use RadTreeView, you need to bind to a DataSet directly. The DataSet needs to have the proper relations set up for its tables and you need to instruct RadTreeView to use these relations as described in our online documentation.
I am looking forward to your reply.
Regards,
Victorthe Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Hi victor,
There are difference way coding between online document and my could you please recommend on my code as below
sqlShowData="Select Field1,Field2 FROM TABLE"
Da =
New SqlDataAdapter(sqlShowData, Conn)
Ds =New DataSet()
Da.Fill(Ds)
Waiting for you help.
amnad
I have try to this way but still cannot.Any one can help me?Or telerik can use only datasource?
sqlShowData="SELECT F FROM TABLE1;SELECT C FROM TABLE2;"
Da =
New SqlDataAdapter(sqlShowData, Conn)
Ds = New DataSet()
Da.Fill(Ds)
Ds.Tables(0).TableName = "A"
Ds.Tables(1).TableName = "B"
Me.rtvDesc.RelationBindings.Add(New RelationBinding("F", Ds.Tables(0)))
Me.rtvDesc.RelationBindings.Add(New RelationBinding("C", Ds.Tables(1)))
Me.rtvDesc.RootRelationDisplayName = "File Name"
Me.rtvDesc.DataSource = Me.Ds
Thanks
In the code below you are adding relations to RelationBindings collection, however, does the DataSet have its the "F" and "the C" relations set up correctly? I am referring to these relations. I am looking forward to your reply.
Greetings,
Victor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Thanks for your help.I can solved this problem with code as below;
sqlShowData="SELECT F FROM TABLE1;SELECT C ,CC FROM TABLE2"
Me.rtvDesc.RelationBindings.Add(New RelationBinding("F", Ds.Tables(0)))
Me.rtvDesc.RelationBindings.Add(New RelationBinding("C", Ds.Tables(1)))
Dim dc1 As DataColumn = Ds.Tables(0).Columns("F")
Dim dc2 As DataColumn = Ds.Tables(1).Columns("C")
Dataset.Relations.Add("Relation",dc1 ,dc2)
The binding to treeview like
Dim FileName As RelationBinding = New RelationBinding("C", Ds)
FileName.DisplayMember =
"CC"
Me.rtvDesc.RelationBindings.Add(FileName)
Me.rtvDesc.DisplayMember = "F"
Me.rtvDesc.RootRelationDisplayName = "File Name"
Me.rtvDesc.DataSource = Ds
My next question is Can telerik treeview display multi child node like.
-F
--CC
----DD
----DD
----DD
--CC
----DD
----DD
----DD
--CC
----DD
----DD
----DD
-F
--CC
----DD
----DD
--CC
How ?
Waiting for your answer.
Thanks
amnad
I have attached a sample application which demonstrates the functionality that you described.
Please write again if you have further questions.
Best wishes,Victor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Regard,
amnad