码迷,mamicode.com
首页 > 其他好文 > 详细

ListBox数据绑定无效

时间:2014-10-14 00:19:47      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   ar   sp   数据   div   log   ad   

    public class DataList
    {
        public List<string> listSource;
        private DataTable table;
        public DataList()
        {
            table = new DataTable();
            table.Columns.Add("column0");
            table.Columns.Add("column1");

            DataRow row = table.NewRow();
            row[0] = "0";
            row[1] = "1";
            table.Rows.Add(row);


            listSource = new List<string>();
            listSource.Add("1");
            listSource.Add("2");
            listSource.Add("3");
            listSource.Add("4");
            listSource.Add("5");
        }
        public DataTable Table
        {
            get { return table; }
            set { table = value; }
        }
    }
}

如果红色部分没有写,就算把table的变为public属性时,绑定数据源无效,绑定数据源时一定要用set ,get 的方法。

ListBox数据绑定无效

标签:style   blog   color   ar   sp   数据   div   log   ad   

原文地址:http://www.cnblogs.com/qq247039968/p/4023220.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!