TreeView刷新C#

时间:2016-05-09 16:05:08

标签: c# asp.net treeview

我的问题是在树视图中创建新节点时,未更新或刷新。我正在使用CodeBehind,当我进入一个新节点时,我没有让我感觉很酷,因为进入一个新的节点我用'模态对话'和连接基础数据。

ASPX:

                <asp:TreeView
                    ID="trv_padre" 
                    ShowLines="true"
                    RootNodeStyle-ImageUrl="~/files/icons/pc.png"
                    ParentNodeStyle-ImageUrl="~/files/icons/folder_close.png"
                    LeafNodeStyle-ImageUrl="~/files/icons/folder_open.png"
                    HoverNodeStyle-BackColor="#2e8965"
                    HoverNodeStyle-ForeColor="White" 
                    runat="server">
                    <NodeStyle Font-Names="Arial" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5"/>
                    <RootNodeStyle Font-Bold="True" Font-Size="9pt"/>
                    <HoverNodeStyle Font-Underline="True"/>      
                    <SelectedNodeStyle ForeColor="Red" />        
                </asp:TreeView>

CLASS:

protected void Page_Load(object sender, EventArgs e)
    {
        M_Treeview();
    }

public void M_Treeview()
        {
            FD_CN objOpe = null;
            FD_CE objEn = null;

            DataTable dta_consulta = null;
            DataTable dta_resultado = null;
            DataView dtw_consulta = null;

            trv_padre.Nodes.Clear();

            objOper= new FD_CN();
            objEnt = new FD_CE();

            dta_consulta = objOper.F_Listar_Nodo_Folder(objEntidad);
            if (dta_consulta != null && dta_consulta.Rows.Count > 0)
            {
                dtw_consulta = dta_consulta.DefaultView;
                dtw_consulta.RowFilter = "ID_FolderDigitalizacionSup = 0";
                dta_resultado = dtw_consulta.ToTable();

                foreach (DataRow dtr_fila in dta_resultado.Rows)
                {
                    TreeNode trn_padre = new TreeNode();

                    String str_id_folder = "";
                    String str_descripcion_folder = "";

                    ...

                    trn_padre.Expand();
                    trv_padre.Nodes.Add(trn_padre);

                    M_Treeview_Nodo(trn_padre, str_id_folder, dta_consulta);

                }

            }    
        }


public int M_Treeview_Nodo(TreeNode trn_par_padre, String str_id, DataTable dta_par_consulta)
    {
        DataTable dta_resultado_hijo = null;
        DataView dtw_consulta_hijo = null;
        String str_id_hijo = "";

        String str_descripcion_padre = "";

        dtw_consulta_hijo = dta_par_consulta.DefaultView;
        dtw_consulta_hijo.RowFilter = "ID_FolderDigitalizacionSup=" + str_id;

        dta_resultado_hijo = dtw_consulta_hijo.ToTable();

        foreach (DataRow dtr_fila_hijo in dta_resultado_hijo.Rows)
        {
            TreeNode trn_hijo = new TreeNode();

            ...

        }
        return 0;
    }

DEMO:http://recordit.co/A5LfbyQCO3 提前谢谢。

0 个答案:

没有答案