public void treeviewdeGoster()
{
DataTable dt = sc("select * from BAKMAgaci where AnaMKA_ID=0", "ConnStr");
TreeNode parent = new TreeNode();
parent.Text = "Makina Agacımız";
parent.Value = "-1";
TreeView1.Nodes.Add(parent);
for (int i = 0; i < dt.Rows.Count; i++)
{
TreeNode parent2 = new TreeNode();
parent2.Text = dt.Rows[i]["Adi"].ToString();
parent2.Value = dt.Rows[i]["MKA_ID"].ToString();
parent.ChildNodes.Add(parent2);
trvDoldur(ref parent2, Convert.ToInt16(dt.Rows[i]["MKA_ID"]));
}
}
int ky = 1;
void trvDoldur(ref TreeNode parent, int parentIdsi)
{
DataTable yedek;
yedek = sc("select * from BAKMAgaci where AnaMKA_ID=" + parentIdsi, "ConnStr");
for (int y = 0; y < yedek.Rows.Count; y++)
{
TreeNode child = new TreeNode();
child.Text = yedek.Rows[y]["Adi"].ToString();
child.Value = yedek.Rows[y]["MKA_ID"].ToString();
parent.ChildNodes.Add(child);
trvDoldur(ref child, Convert.ToInt16(yedek.Rows[y]["MKA_ID"]));
}
ky--;
}