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

相关文章:

  • 2021-07-30
  • 2021-08-11
  • 2021-08-20
  • 2022-12-23
  • 2021-05-07
  • 2022-12-23
  • 2022-01-04
猜你喜欢
  • 2021-10-29
  • 2021-06-09
  • 2022-12-23
  • 2021-07-19
  • 2021-09-15
  • 2022-12-23
  • 2021-04-26
相关资源
相似解决方案