zoukankan      html  css  js  c++  java
  • (DevExpress2011控件教程)ASPxTreeList 范例1 :如何绑定数据到ASPxTreeList

    前言

    刚好公司项目中使用DevExpress的控件进行系统开发,在开发过程中遇到各种各样的困难,我总结项目中的经验,力所能及的把经验的点滴为大家呈现。如有不足之处请各位指点。后续文章中会把实际工作中的例子与大家共享。

    其实官网也为大家提供了不少好的例子,都是英文。

    数据结构

     

    表名 : dpt

    dptID         int

    dptname      varchar(100)

    dptFatherID    int

    1.       新建一个项目

     

    2.       新建一个页面 treeListDataBind

     

     

    3.       在左边的菜单中拖出TreeList控件

     

     4.       数据绑定

           Database db = DatabaseFactory.CreateDatabase();

            protected void Page_Load(object sender, EventArgs e)

            {

                if (!IsPostBack)

                {

                    TreeDataBind();

                    treeList.ExpandToLevel(2);

                }

            }

     

            private void TreeDataBind()

                {

                   string Sql="select * from com_Dpt";

                   DataSet ds= db.ExecuteDataSet(System.Data.CommandType.Text, Sql);

                   treeList.DataSource =ds.Tables[0];

                   treeList.KeyFieldName = "dptid";

                   treeList.ParentFieldName = "dptfatherid";

                   treeList.DataBind();

                }

    运行一下。你可以看到如下效果

  • 相关阅读:
    HDU 1069 Monkey and Banana
    HDU 1029 Ignatius and the Princess IV
    HDU 1024 Max Sum Plus Plus
    Gym100923H Por Costel and the Match
    Codeforces 682C Alyona and the Tree
    Codeforces 449B Jzzhu and Cities
    Codeforces (ccpc-wannafly camp day2) L. Por Costel and the Semipalindromes
    Codeforces 598D (ccpc-wannafly camp day1) Igor In the Museum
    Codeforces 1167c(ccpc wannafly camp day1) News Distribution 并查集模板
    快乐数问题
  • 原文地址:https://www.cnblogs.com/meetweb/p/2148610.html
Copyright © 2011-2022 走看看