Add new child in TreeView from TextBox in database?

testball

New Member
I have use the code below. And this tables in my database. I have textbox and button and i want on button click to be possible to add new child on Leaf1,Leaf2...What change i need to make and write in my code:
lTvKW.jpg
I2bDS.jpg
Output display:
thxji.jpg
\[code\]protected void Page_Load(object sender, EventArgs e){ fill_Tree2();}void fill_Tree2(){ DataSet PrSet = PDataset("Select * from ParentTable"); TreeView1.Nodes.Clear(); foreach (DataRow dr in PrSet.Tables[0].Rows) { TreeNode tnParent = new TreeNode(); tnParent.Text = dr["ParentName"].ToString(); tnParent.Value = http://stackoverflow.com/questions/12598939/dr["ParentID"].ToString(); tnParent.PopulateOnDemand = true; tnParent.ToolTip = "Click to get Child"; tnParent.SelectAction = TreeNodeSelectAction.SelectExpand; tnParent.Expand(); tnParent.Selected = true; TreeView1.Nodes.Add(tnParent); FillChild(tnParent, tnParent.Value); }}public void FillChild(TreeNode parent, string ParentId){ DataSet ds = PDataset("Select * from ChildTable where ParentId =" + ParentId); parent.ChildNodes.Clear(); foreach (DataRow dr in ds.Tables[0].Rows) { TreeNode child = new TreeNode(); child.Text = dr["ChildName"].ToString().Trim(); child.Value = http://stackoverflow.com/questions/12598939/dr["ChildId"].ToString().Trim(); if (child.ChildNodes.Count == 0) { child.PopulateOnDemand = true; } child.ToolTip = "Click to get Child"; child.SelectAction = TreeNodeSelectAction.SelectExpand; child.CollapseAll(); parent.ChildNodes.Add(child); }}protected DataSet PDataset(string Select_Statement){ SqlConnection SqlCon = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=cms;Integrated Security=True"); SqlDataAdapter ad = new SqlDataAdapter(Select_Statement, SqlCon); DataSet ds = new DataSet(); ad.Fill(ds); return ds;}\[/code\]
 
Back
Top