-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: DetailsView control & Nhibernate
PostPosted: Sat Apr 22, 2006 2:40 pm 
Regular
Regular

Joined: Fri Feb 03, 2006 5:28 pm
Posts: 73
Location: Québec, QC, Canada
Check out this tutorial ( http://www.asp.net/QuickStart/aspnet/do ... sview.aspx ).

In the detailview page there is something like

<asp:DetailsView ID="DetailsView1" Runat="server" DataSourceID="SqlDataSource1" AutoGenerateRows="False"
HeaderText="Books for Author" AllowPaging="True">
<Fields>
<asp:BoundField HeaderText="au_id" DataField="au_id" SortExpression="au_id" />
<asp:BoundField HeaderText="title_id" DataField="title_id" SortExpression="title_id" />
<asp:BoundField HeaderText="title" DataField="title" SortExpression="title" />
<asp:BoundField HeaderText="type" DataField="type" SortExpression="type" />
<asp:BoundField HeaderText="price" DataField="price" SortExpression="price" />
<asp:BoundField HeaderText="notes" DataField="notes" SortExpression="notes" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource1" Runat="server" SelectCommand="SELECT dbo.authors.au_id, dbo.titles.title_id, dbo.titles.title, dbo.titles.type, dbo.titles.price, dbo.titles.notes FROM dbo.authors INNER JOIN dbo.titleauthor ON dbo.authors.au_id = dbo.titleauthor.au_id INNER JOIN dbo.titles ON dbo.titleauthor.title_id = dbo.titles.title_id WHERE (dbo.authors.au_id = @au_id)"

ConnectionString="<%$ ConnectionStrings:Pubs %>">
<SelectParameters>
<asp:QueryStringParameter Name="au_id" DefaultValue="213-46-8915" QueryStringField="ID" />
</SelectParameters>
</asp:SqlDataSource>



that's cool, but if I'm using NHibernate, how can I achieve the same result since I don't want to use the connection string / Sql Select statement ? Any idea ?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 22, 2006 4:19 pm 
Senior
Senior

Joined: Wed Jun 15, 2005 4:17 am
Posts: 156
you have to replace the SqlDataSource control with an ObjectDataSource.

cheers,
radu


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 22, 2006 6:26 pm 
Regular
Regular

Joined: Fri Feb 03, 2006 5:28 pm
Posts: 73
Location: Québec, QC, Canada
great!

and let's say I have a class Address and a class Client that has an Address type property..

is there any way to use a DetailsView to display a Client with his address as well as edit both ?

Thanks for the quick reply :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 24, 2006 10:40 am 
Beginner
Beginner

Joined: Wed Apr 19, 2006 9:16 am
Posts: 24
I don't think the out of the box ObjectDataSource can bind against nested class properties, at least not editable ones. The best way to go would be to write a custom datasource, or use a workaround as shown here:

http://forums.asp.net/974170/ShowPost.aspx


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 24, 2006 10:45 am 
Regular
Regular

Joined: Fri Feb 03, 2006 5:28 pm
Posts: 73
Location: Québec, QC, Canada
Thanks.. the asp.net solution seems pretty easy :)

I think I'll give a shot a custom data source obj.. anyways !

thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.