StrataFrame Forum

Datagrid Issues

http://forum.strataframe.net/Topic10943.aspx

By Scott Hershberger - 8/20/2007

I need to fill a datagrid based on multiple tables in the database. I got this accomplished by adding custom values to the bo and it works great. It's very fast. I am now having two issues though. One, I cannot sort on a custom value column. I simply get a column not found error. Second, and this may be .net related, when I close .net and open it again, my datagrid is filled in, not only with the columns that I had previously specified, but with everything from the BO added on, even copies of what I already had there. Does anyone have any idea how to fix either of these?



Thanks
By Trent L. Taylor - 8/20/2007

One, I cannot sort on a custom value column.

This is because your custom property is more than likely not pulling from a column in the internal DataTable.  You can create your own Comparer class to sort as you need.  But in most cases, this has to do with the code behind the custom column.

and this may be .net related, when I close .net and open it again, my datagrid is filled in, not only with the columns that I had previously specified, but with everything from the BO added on, even copies of what I already had there. Does anyone have any idea how to fix either of these?

OK, you have something else going on here.  Once a BO is destroyed, cleared, etc. there is no data in it any longer.  So the BO MUST be populated before the grid can show any data.  I do not know what type of grid you are using, but it sounds as if there is some type of serialization or caching going on here.  I have never heard of something like this being done automatically.  I have seen this type of functionality done programatically and intentionally, but not by accident.

By Scott Hershberger - 8/21/2007

Thanks Trent,



Point A is not understood. I think the problem with B is that I did not explain it well enough. What is filling is is column headers.



As an example, I have it filled with patient Name , address , phone



Everything works great. Then I close .net and open it again and now the datagrid has



Name, address , phone, date , nickname , ..., Name, Address, phone



I have to delete all the added column headers or they will fill in with data when the bo is populated.



Any idea on this?
By Trent L. Taylor - 8/21/2007

Point A is not understood.

Well, this is a more lengthy topic and a brief answer is not very easy.  There are a lot of ways to sort within .NET.  When you bind to a grid, it expects the IBindingList interface.  The SF BusinessBindingSource provides a way to wrap a business object with this interface.  The way the grid interprets this is that each row is a unique business object with the value that is on that specific row.  So when you start introducing custom columns for soirting, I would have to understand what your custom field is even doing before I could give you much of an answer.

Any idea on this?

OK.  This is your grid not serializing the columns that were created the last time you were in teh designer...or...it is overwriting the columns that were saved.  This is the grid, not SF.  When you define the columns to show in the grid, it will create a collection and store this in a grid property.  Depending which grid you are using this will be different everytime.  But the one thing that is consistent regardless of the grid type is that it will save this to the .designer file so the next time you come back in it will load up its column collection and know which columns will be in the grid.  Your designer is not remembering this for some reason.  This too can be caused from a large number of things and giving a concrete answer to the exact cause would be difficult at best.  The the reason the columns are not remembered is because of the .designer file or the constructor code of the grid.

By Scott Hershberger - 8/21/2007

I meant point A is now understood.



Thanks for the answer on B!
By Trent L. Taylor - 8/21/2007

Ahh...got it BigGrin