ListBox数据绑定无效

    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 的方法。

posted @ 2014-10-13 22:11  玖彩技术团队  阅读(314)  评论(0编辑  收藏  举报
以上只是个人想法和实践经验,如果有文字错误和语法错误,请加以指点! QQ:247039968 emil:wujc@younger.com 无论是美女的歌声,还是鬣狗的狂吠,无论是鳄鱼的眼泪,还是恶狼的嚎叫,都不会使我动摇