Create treeview with sqlCommand

10 posts, 0 answers
  1. Amnad Lueaipang
    Amnad Lueaipang avatar
    8 posts
    Member since:
    Jul 2012

    Posted 09 Dec 2009 Link to this post

    Hi Telerik support team
    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

  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 11 Dec 2009 Link to this post

    Hi Amnad Lueaipang,

    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.

    Please write again if you have other questions.

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Amnad Lueaipang
    Amnad Lueaipang avatar
    8 posts
    Member since:
    Jul 2012

    Posted 11 Dec 2009 Link to this post

    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

     

     

  5. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 14 Dec 2009 Link to this post

    Hi Amnad Lueaipang,

    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,

    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.
  6. Amnad Lueaipang
    Amnad Lueaipang avatar
    8 posts
    Member since:
    Jul 2012

    Posted 15 Dec 2009 Link to this post

    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

     

     

     

     

     

     

  7. Amnad Lueaipang
    Amnad Lueaipang avatar
    8 posts
    Member since:
    Jul 2012

    Posted 22 Dec 2009 Link to this post

    Hi..Telerik team,
    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

     

  8. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 28 Dec 2009 Link to this post

    Hello Amnad Lueaipang,

    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.
  9. Amnad Lueaipang
    Amnad Lueaipang avatar
    8 posts
    Member since:
    Jul 2012

    Posted 05 Jan 2010 Link to this post

    Hi Victor,

    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


     

     

     

     

     

     

  10. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 07 Jan 2010 Link to this post

    Hi Amnad Lueaipang,

    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.
  11. Amnad Lueaipang
    Amnad Lueaipang avatar
    8 posts
    Member since:
    Jul 2012

    Posted 07 Jan 2010 Link to this post

    Good sample.Thank you for your help.
    Regard,
    amnad 
Back to Top
UI for WinForms is Visual Studio 2017 Ready