Latest Updates …
Comments: Flat Nested Threaded Embedded Oldest First Newest First Templates rock! By jensenkd on Saturday, March 19, 2005 (EST) Paul, Your templates rock! I'm wondering what best practices are when binding a collection of custom objects to a datagrid are. I have a List of 'Contact' objects. The Contact object contains an 'User' object as Owner of the contact. How can I expose the properties of the User object to the datagrid? I could create read-only properties on the Contact object that refer to the User Object. Is this the best way to do it? Keep up the great work! Kevin Reply to this Comment Template Column Example By pwelter34 on Saturday, March 19, 2005 (EST) Kevin, The easiest way to display a property of a child object is to create Template Column. Example ...<asp:TemplateColumn SortExpression="UserID" HeaderText="User Name"> <ItemTemplate> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.UserObject.Name") %>'> </asp:Label> </ItemTemplate></asp:TemplateColumn> In the above example, DataItem is an instance of Contact, UserObject is a property of Contact. UserObject is assumed to have been created by the template because there is a foreign key from Contact table to User table. Finally, Name is a property of User. Hope that helps,~Paul Reply to this Comment WOW By jensenkd on Saturday, March 19, 2005 (EST) I can't believe I didn't know you could call inner classes that way. I feel so dumb. Thank you Peter! Reply to this Comment Many-Many mapping? By martigno on Friday, March 25, 2005 (EST) Paul, First, thanks for your work on the templates, they rock! My question is about the many to many mapping capability. I'm using a SQL 2000 db and have three tables (very similar to your example of role->user->userrole. The userrole table has two “foriegn key relationships” defined in it but when I gen the mapping file, I don't get the many to many mapping I thought I would get. Is there something else I need to be defining on the tables to get the many-many mapping to be picked up? Thanks in advance,Jeff Reply to this Comment Many-Many Mappings? By martigno on Friday, March 25, 2005 (EST) Just found it. The templete requires that the intermediate template (userrole) have only two columns. It did pick up the many-many relationship then. Thanks,Jeff Reply to this Comment Can't see relations By dugrless on Wednesday, March 30, 2005 (EST) I love these templates, but I can't seem to get them to show my MySql relationships. I'm using MySql 4.1.10 and the lastest MySqlSchemaProvider from over at the CodeSmith forums (http://www.ericjsmith.net/codesmith/forum/default.aspx?f=9&m=4357&p=1&ord=d). Any help would be greatly appreciated! Reply to this Comment New MySqlSchemaProvider By dugrless on Wednesday, April 06, 2005 (EST) For anyone else using these templates with MySql, I've just uploaded a new version of MySqlSchemaProvider over on the CodeSmith forums (http://www.ericjsmith.net/codesmith/forum/default.aspx?f=10&m=2900&p=1&ord=d). I redesigned the provider specifically to work with these templates, so it now correctly exposes foreign keys (in InnoDB tables at least) as well as auto_number identity columns. Have fun! Reply to this Comment eats disaster spreads across the globe. By wbondarmunw on Thursday, May 01, 2008 (EST) All greetings... I faith that chose the decent leg of it for asking your inconceivable, if not, sorry. I do not awfully many times go to the forums. And my, my inconceivable is what is: How do you deliberate on how moment the tough nut to crack of guerdon increases, and whether it is practical broad shock, the deed data that already incident, namely: Rising grub charges has transformed subsistence into an ecumenical gin excess ofnmental issue. Riots make erupted in Egypt, Haiti and Bangladesh closed soaring grub tolls. People fought one another remaining bags of rice in West Africa. The causes and the solutions to the grub calamity are complex. Iif not knotty and you pull someone's leg your theory on this, suit rejoin, I am unundoubtedlyably interested to listen to your conception. See you later! P.S. Sorry for my english. Reply to this Comment
Paul,
Your templates rock!
I'm wondering what best practices are when binding a collection of custom objects to a datagrid are.
I have a List of 'Contact' objects. The Contact object contains an 'User' object as Owner of the contact.
How can I expose the properties of the User object to the datagrid? I could create read-only properties on the Contact object that refer to the User Object. Is this the best way to do it?
Keep up the great work!
Kevin
Reply to this Comment
Kevin,
The easiest way to display a property of a child object is to create Template Column. Example ...
<asp:TemplateColumn SortExpression="UserID" HeaderText="User Name"> <ItemTemplate> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.UserObject.Name") %>'> </asp:Label> </ItemTemplate></asp:TemplateColumn>
In the above example, DataItem is an instance of Contact, UserObject is a property of Contact. UserObject is assumed to have been created by the template because there is a foreign key from Contact table to User table. Finally, Name is a property of User.
Hope that helps,~Paul
I can't believe I didn't know you could call inner classes that way.
I feel so dumb.
Thank you Peter!
First, thanks for your work on the templates, they rock!
My question is about the many to many mapping capability. I'm using a SQL 2000 db and have three tables (very similar to your example of role->user->userrole. The userrole table has two “foriegn key relationships” defined in it but when I gen the mapping file, I don't get the many to many mapping I thought I would get.
Is there something else I need to be defining on the tables to get the many-many mapping to be picked up?
Thanks in advance,Jeff
Just found it. The templete requires that the intermediate template (userrole) have only two columns. It did pick up the many-many relationship then.
Thanks,Jeff