Domain Tables Question
Old forum URL: forums.lhotka.net/forums/t/1159.aspx
mr_lasseter posted on Thursday, September 07, 2006
How are people allowing domain tables to be updated in the front end application (windows forms)?
Before using CSLA.Net, I did the following which was pretty easy to implement.
1. All domain classes would implement a IDomain interface (GetAll, Add, Edit, Delete)
2. I had one form that contained a listview which when loaded will call the getall (returned a dataset) and loaded the dataset into the listview
3. The user could click an add, edit, or delete button, all of which passed the listviewitem to the class. The class knew how to populate itself based on the listviewitem passed to it. It also knew what add/edit window to call for updating.
The most important part of this I could do this using one display form (and the column headers were displayed using aliases in the SQL) and 1 edit window for each table. Using Databinding and CSLA.Net I don't see how to accomplish this without creating a 2 forms one to display the list and one to edit the table.
What am I missing?
Thanks in advance,
Mike
Brian Criswell replied on Friday, September 08, 2006
You could use a DataGridView to both view and edit the list. To decide on the columns, iterate over the properties and skip any that are marked with the IsBrowseable(false) attribute.
mr_lasseter replied on Friday, September 08, 2006
Is there an easy way to rename the column headings on the fly? What about the order of the columns? Brian Criswell replied on Friday, September 08, 2006
You could clear the columns and recreate them whenever your data source changes.
mr_lasseter replied on Friday, September 08, 2006
I guess this is where MVC proves itself to be so valuable? I am assuming the form should just know that it displays the data source in a datagridview, but the control knows what the column headers should be?ajj3085 replied on Friday, September 08, 2006
The grid can 'figure out' what your columns are by looking at the public properties of your business object. Alternately, you can create the columns yourself. The form doesn't necesarly care about what data is in the grid, unless you need it to for some reason.
mr_lasseter replied on Friday, September 08, 2006
I understand that, but the grid cannot figure out what the Display Name should be (ie. property UserID should display as User ID).
Brian Criswell replied on Friday, September 08, 2006
You could put that in your resources file and then retrieve it with a method that turns the object and property into a string and retrieves that from the resources file.
System.Resources.ResourceManager.GetString("Namespace_Object_Property", ResourceManager.Culture);
mr_lasseter replied on Friday, September 08, 2006
This is something I will look into. Thanks for your time.
Copyright (c) Marimer LLC