button如何取的treeview的节点
button如何取的treeview的节点:
页面左边有个treeview用来显示单位
右边有button用来查询的,有一系列的下拉框用来拼接sql条件的
<asp:TreeView ID="TreeView1" runat="server" OnSelectedNodeChanged="TreeView1_SelectedNodeChanged"
OnLoad="TreeView1_Load">
<SelectedNodeStyle ForeColor="Red" Font-Bold="True" />
</asp:TreeView>
我的代码为
protected void btnSearch_Click(object sender, EventArgs e)
{
ViewState["DropDownList1"] = DropDownList1.SelectedValue;
ViewState["DropDownList2"] = DropDownList2.SelectedValue;
string startdate = DropDownList1.SelectedValue + DropDownList2.SelectedValue;
if (zzjg == "dydm")
{
if (TreeView1.SelectedNode.Depth == 2 && TreeView1.SelectedNode.ChildNodes.Count == 0)
{
Dictionary<string, string> yqt = sql_Organization1(a);
foreach (var y in yqt)
{
if (yqt.Count > 0)
{
TreeView1.SelectedNode.ChildNodes.Add(new TreeNode(y.Value, y.Key));
}
}
}
}
if (TreeView1.SelectedNode.ChildNodes.Count == 0)???????????
我这个条件就取不到树形节点,老是为空错在这里的
{
...... //井别分类提示 1 油井 2 气井 3 水井
&nb