BindingSource.Count not always right
Hi
I am using a BindingSource for my app. When I set it's DataSource to be a DataSet I have created on the fly it tells me that BindingSource.Count = 0. Looking at the data I can see that there are 1000 rows in the DataSet - why does it tell me the count is 0?
Thanks
you have to set the datamember property.
the following code should give you an idea
DataTable dt = new DataTable("datatable1");
dt.Columns.Add("col1");
dt.Columns.Add("col2");
dt.Rows.Add("123", "abc");
dt.Rows.Add("234", "bcd");
dt.Rows.Add("345", "cde");
DataTable dt2 = new DataTable();
DataSet dset = new DataSet();
dset.Tables.Add(dt);
dset.Tables.Add(dt2);
BindingSource bs = new BindingSource();
bs.DataMember = "datatable1";
bs.DataSource = dset;
countRows = bs.Count;