Hello
I am working on radtreeview control. I am new to telerik controls
I am having a problem, see if you guys can help me on it.
I am trying to set default static root for the categories, I have database table name called categories, has iID and iParent columns that make relation of parent and child.
I want to achieve treeview like this.
Root
|-child1
|-child2
|-child3
|-child3a
|-child3b
|-child4
|-child5
|-child6
but i am gettign all child1 to child 6 at root line including root.
here is the code
SqlConnection conn = new SqlConnection(Global.SQLConnectionString);
conn.Open();
string sqlString;
//sqlString = "SELECT * FROM [MediaLibraryCategories]";
sqlString = "Select iID,Title,iParent From Categories Union All Select '0','root', -1 Order By Sort";
SqlCommand Cmd = new SqlCommand(sqlString, conn);
try
{
SqlDataReader Dr = Cmd.ExecuteReader();
RadTreeView1.DataFieldID = "iID";
RadTreeView1.DataFieldParentID = "iParent";
RadTreeView1.DataTextField = "Title";
RadTreeView1.DataValueField = "iID";
RadTreeView1.DataSource = Dr;
RadTreeView1.DataBind();
}
with Union All, 0 is the iID, root is the title, and -1 is the iParent
other data are like this..
iID, Title, iParent
1 child1 0
2 child2 0
3 child3 0
4 child4 0
5 child5 0
6 child6 0
7 child3a 3
8 child3b 3
Union All
0 Root -1
Thanks,
I am working on radtreeview control. I am new to telerik controls
I am having a problem, see if you guys can help me on it.
I am trying to set default static root for the categories, I have database table name called categories, has iID and iParent columns that make relation of parent and child.
I want to achieve treeview like this.
Root
|-child1
|-child2
|-child3
|-child3a
|-child3b
|-child4
|-child5
|-child6
but i am gettign all child1 to child 6 at root line including root.
here is the code
SqlConnection conn = new SqlConnection(Global.SQLConnectionString);
conn.Open();
string sqlString;
//sqlString = "SELECT * FROM [MediaLibraryCategories]";
sqlString = "Select iID,Title,iParent From Categories Union All Select '0','root', -1 Order By Sort";
SqlCommand Cmd = new SqlCommand(sqlString, conn);
try
{
SqlDataReader Dr = Cmd.ExecuteReader();
RadTreeView1.DataFieldID = "iID";
RadTreeView1.DataFieldParentID = "iParent";
RadTreeView1.DataTextField = "Title";
RadTreeView1.DataValueField = "iID";
RadTreeView1.DataSource = Dr;
RadTreeView1.DataBind();
}
other data are like this..
iID, Title, iParent
1 child1 0
2 child2 0
3 child3 0
4 child4 0
5 child5 0
6 child6 0
7 child3a 3
8 child3b 3
Union All
0 Root -1
Thanks,