tree view select all child nodes when to click parent nodes
-
I have tree view control on my asp.net web page. this tree control has check boxes on every node. I want when user selects or make parent node check box checked then its child should also get checked automatically. how can i do this ? kindly its urgent, plz send some code hints.
-
I have tree view control on my asp.net web page. this tree control has check boxes on every node. I want when user selects or make parent node check box checked then its child should also get checked automatically. how can i do this ? kindly its urgent, plz send some code hints.
Write some fancy javascript to update all the sub nodes that contain a checkbox, or put the treeview in an ajax panel and use server side code to check all the checkboxes.
I didn't get any requirements for the signature
-
Write some fancy javascript to update all the sub nodes that contain a checkbox, or put the treeview in an ajax panel and use server side code to check all the checkboxes.
I didn't get any requirements for the signature
-
we r using asp.net and we have also created check boxes, we want parent node check box checked then its child should also get checked automatically.
-
enumerate though the childnodes and check the checkboxes. Post your code so you can get further help.
heres the code
public partial class _Default : System.Web.UI.Page
{
public static SqlConnection sqlConn = new SqlConnection();
public static SqlCommand sqlCmmd = new SqlCommand();
public static SqlDataAdapter sqlDAptr = new SqlDataAdapter();
//public DataSet busDataSet
//{
// get
// {
// return DS;
// }
// set
// {
// DS = value;
// }
//}protected void Page\_Load(object sender, EventArgs e) { try { //GetTables(); PassQuery(); //abc(); } catch (Exception) { throw; } } public void PassQuery() { this.TreeView1.Nodes.Clear(); DataSet myFirstTable = new DataSet(); string Query = "select name from sys.tables"; myFirstTable = Retun\_Table\_BasedOn\_Query(Query); DataSet\[\] mySecondTable = new DataSet\[myFirstTable.Tables\[0\].Rows.Count\]; for (int i = 0; i < myFirstTable.Tables\["Table"\].Rows.Count; i++) { string str1 = myFirstTable.Tables\["Table"\].Rows\[i\]\[0\].ToString(); string Query2 = "SELECT sysobjects.name As Names, syscolumns.name AS FieldName " + "FROM sysobjects INNER JOIN syscolumns ON sysobjects.id = syscolumns.id " + "WHERE (sysobjects.name = '" + str1 + "')"; mySecondTable\[i\] = Retun\_Table\_BasedOn\_Query(Query2); TreeNode tnParent; TreeNode tnChild; for (int a = 0; a < 1; a++) { tnParent = new TreeNode(); tnParent.Text = str1.ToString(); TreeView1.Nodes.Add(tnParent); foreach (DataRow rowChild in mySecondTable\[i\].Tables\["Table"\].Rows) { tnChild = new TreeNode(); tnChild.Text = rowChild\["FieldName"\].ToString(); tnParent.ChildNodes.Add(tnChild); } } } } public void Open\_Connection() { string Conn\_Str = "Data Source=dev-test;Initial Catalog=Malik;Persist Security Info=True;User ID=interns;Password=intern123"; sqlConn = new SqlConnection(Conn\_Str); if (sqlConn.State != ConnectionState.Open) { sqlConn.Open(); } } public DataSet Retun\_Table\_BasedOn\_Query(String Quer
-
heres the code
public partial class _Default : System.Web.UI.Page
{
public static SqlConnection sqlConn = new SqlConnection();
public static SqlCommand sqlCmmd = new SqlCommand();
public static SqlDataAdapter sqlDAptr = new SqlDataAdapter();
//public DataSet busDataSet
//{
// get
// {
// return DS;
// }
// set
// {
// DS = value;
// }
//}protected void Page\_Load(object sender, EventArgs e) { try { //GetTables(); PassQuery(); //abc(); } catch (Exception) { throw; } } public void PassQuery() { this.TreeView1.Nodes.Clear(); DataSet myFirstTable = new DataSet(); string Query = "select name from sys.tables"; myFirstTable = Retun\_Table\_BasedOn\_Query(Query); DataSet\[\] mySecondTable = new DataSet\[myFirstTable.Tables\[0\].Rows.Count\]; for (int i = 0; i < myFirstTable.Tables\["Table"\].Rows.Count; i++) { string str1 = myFirstTable.Tables\["Table"\].Rows\[i\]\[0\].ToString(); string Query2 = "SELECT sysobjects.name As Names, syscolumns.name AS FieldName " + "FROM sysobjects INNER JOIN syscolumns ON sysobjects.id = syscolumns.id " + "WHERE (sysobjects.name = '" + str1 + "')"; mySecondTable\[i\] = Retun\_Table\_BasedOn\_Query(Query2); TreeNode tnParent; TreeNode tnChild; for (int a = 0; a < 1; a++) { tnParent = new TreeNode(); tnParent.Text = str1.ToString(); TreeView1.Nodes.Add(tnParent); foreach (DataRow rowChild in mySecondTable\[i\].Tables\["Table"\].Rows) { tnChild = new TreeNode(); tnChild.Text = rowChild\["FieldName"\].ToString(); tnParent.ChildNodes.Add(tnChild); } } } } public void Open\_Connection() { string Conn\_Str = "Data Source=dev-test;Initial Catalog=Malik;Persist Security Info=True;User ID=interns;Password=intern123"; sqlConn = new SqlConnection(Conn\_Str); if (sqlConn.State != ConnectionState.Open) { sqlConn.Open(); } } public DataSet Retun\_Table\_BasedOn\_Query(String Quer
T_Teef wrote:
Open_Connection(); DataSet mydataSet = new DataSet(); sqlCmmd = new SqlCommand(Query, sqlConn); sqlDAptr = new SqlDataAdapter(sqlCmmd); sqlDAptr.Fill(mydataSet); return mydataSet;
FYI. If you pass an open connection to a SqlDataAdapter it will not close automatically. Check your sql server you probably have a bunch open connections that aren't being closed. Also, where is your code to handle the treeviews click event?
I didn't get any requirements for the signature
-
T_Teef wrote:
Open_Connection(); DataSet mydataSet = new DataSet(); sqlCmmd = new SqlCommand(Query, sqlConn); sqlDAptr = new SqlDataAdapter(sqlCmmd); sqlDAptr.Fill(mydataSet); return mydataSet;
FYI. If you pass an open connection to a SqlDataAdapter it will not close automatically. Check your sql server you probably have a bunch open connections that aren't being closed. Also, where is your code to handle the treeviews click event?
I didn't get any requirements for the signature