问题描述
各位大虾:使用treeview的时候,我点击结点,第一次没有反应,第二次才能够点开链接。点击其他节点之后,再点击之前链接过的结点,没有任何反应。不知道是怎么回事?我所有链接都链接向同一个链接页面,只是使用不同的取数参数(session传值),显示dropdownlist和Gridview.A--A1|B--B1|C--C1比如点击A1结点,第一次没有反应,第二次点击后链接到相应页面。点击B1,也是这样。点击B1后再点击A1,就发现A1点击没有任何反应。怎么回事?代码:TREE页面:publicpartialclassTreeMenu:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){if(!IsPostBack){//TreeView2.SelectedNode.NavigateUrl="~/flowlist.aspx";}}protectedvoidTreeView2_SelectedNodeChanged(objectsender,EventArgse){Session["node"]=null;Session["parent"]=null;Session["parent"]=TreeView2.SelectedNode.Parent.Text;Session["node"]=TreeView2.SelectedNode.Text;TreeView2.SelectedNode.NavigateUrl="~/flowlist.aspx";//TreeView2.SelectedNode.Target="RightWeb";}}链接页面:publicpartialclassflowlist:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){if(Session["UserName"]==null){Response.Redirect("~/Login.aspx");}else{if(Session["UserName"].ToString().Length==0){Response.Redirect("~/Login.aspx");}if(!Page.IsPostBack){stringMyConString=System.Configuration.ConfigurationManager.AppSettings["Conn"];SqlConnectioncon=newSqlConnection(MyConString);con.Open();stringnode=Session["node"].ToString();stringparent=Session["parent"].ToString();stringstrSql="selectsubjectfromsubjectwherecompany='"+node+"'andflow='"+parent+"'";SqlCommandcmd=newSqlCommand(strSql,con);SqlDataReadersdr=cmd.ExecuteReader();this.DropDownList1.DataSource=sdr;this.DropDownList1.DataTextField="subject";this.DropDownList1.DataValueField="subject";this.DropDownList1.DataBind();sdr.Close();stringsubject="selectID,namefromdirectorywherecompany='"+node+"'andflow='"+parent+"'andfolder='"+DropDownList1.SelectedItem.Value+"'";SqlDataAdaptermyda=newSqlDataAdapter(subject,con);DataSetmyds=newDataSet();myda.Fill(myds,"directory");//SqlCommandcmd=newSqlCommand(strSql,con);//SqlDataReadersdr=cmd.ExecuteReader();GridView1.DataSource=myds;GridView1.DataKeyNames=newstring[]{"ID"};GridView1.DataBind();con.Close();//stringtxtname="selectnamefromdirectory";//SqlCommandcmd1=newSqlCommand(txtname,con);//SqlDataReadersdr1=cmd1.ExecuteReader();//GridView1.DataSource=sdr1;//GridView1.DataBind();}}}protectedvoidGridView1_PageIndexChanging(objectsender,GridViewPageEventArgse){stringMyConString=System.Configuration.ConfigurationManager.AppSettings["Conn"];SqlConnectioncon=newSqlConnection(MyConString);stringnode=Session["node"].ToString();stringparent=Session["parent"].ToString();stringsubject="selectID,namefromdirectorywherecompany='"+node+"'andflow='"+parent+"'andfolder='"+DropDownList1.SelectedItem.Value+"'";SqlDataAdaptermyda=newSqlDataAdapter(subject,con);DataSetmyds=newDataSet();myda.Fill(myds,"directory");GridView1.DataSource=myds;GridView1.DataKeyNames=newstring[]{"ID"};GridView1.PageIndex=e.NewPageIndex;GridView1.DataBind();}protectedvoidDropDownList1_SelectedIndexChanged(objectsender,EventArgse){stringMyConString=System.Configuration.ConfigurationManager.AppSettings["Conn"];SqlConnectioncon=newSqlConnection(MyConString);con.Open();stringnode=Session["node"].ToString();stringparent=Session["parent"].ToString();stringsubject="selectID,namefromdirectorywherecompany='"+node+"'andflow='"+parent+"'andfolder='"+DropDownList1.SelectedItem.Value+"'";SqlDataAdaptermyda=newSqlDataAdapter(subject,con);DataSetmyds=newDataSet();myda.Fill(myds,"directory");//SqlCommandcmd=newSqlCommand(strSql,con);//SqlDataReadersdr=cmd.ExecuteReader();GridView1.DataSource=myds;GridView1.DataKeyNames=newstring[]{"ID"};GridView1.DataBind();con.Close();}}
解决方案
解决方案二:
你换个方法SelectedNodeChanged换成Click试试
解决方案三:
可是结点没有CLICK事件呀
解决方案四:
SelectedNodeChanged方法不用click的默认treeviewnode是0你随便点就变化了