Click to See Complete Forum and Search --> : DataGridView.AutoGenerateColumns problem. Help!!


krzysieq
February 8th, 2007, 08:42 AM
Hi. There's this little big problem I have. There's a data set (customerDS), which I want a DataGridView object to be bound to. So here's the code:

DataView dataView = new DataView(customerDS.CustomerTable);
dataGridView.InnerDataGridView.AutoGenerateColumns = true;
dataGridView.InnerDataGridView.DataSource = dataView;

dataGridView is an object that has a property InnerDataGridView pointing to DataGridView object.

The trouble is that the data set used can be filled from cache or from an sql server query. Obviously the more common way is from cache. And it works fine as long as the application is in the "Online" mode. In "Offline", whereby the data set is absolutely no different (compared property vs property!), for some reason the automatic generation of columns doesn't work. I repeat! The data set in both modes is absolutely the same, it comes from exactly the same cache (Microsoft.Practices.EnterpriseLibrary.Caching), has exactly the same columns and rows, and all other stuff too. Does anybody have a clue why this might be happening? Obviously it's not the question of cache used since System.Web.Caching has also been tried (and failed).
Help.

---
Maybe someone will be able to help me if I put the problem otherwise. Suppose I don't want to use AutoGenerateColumns (stupid, aren't I?) Instead, I'd like to have the grid initialized the DIY-way. What properties should I set on each column in order to get things right? I suppose there's a problem in getting the readonly IsDataBound property to show "true" (which is the case when I use AutoGenerateColumns and it works, but not in any other situation)? Please help...

krzysieq