-->
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: Please help nhibernate > ASP.NET Databinding
PostPosted: Thu Oct 26, 2006 5:51 pm 
Newbie

Joined: Thu Oct 26, 2006 5:34 pm
Posts: 3
can anybody explane why this dose not work? is it posible to do it diffrently?
DropDownList1.DataValueField = "Vidskiptamadur.Heiti";


List l = session.CreateQuery("from PontunLinur v where v.Vidskiptamadur.Kennitala = '5002696779'").SetMaxResults(10).List();

//This dosen't work
DropDownList1.DataValueField = "Vidskiptamadur.Heiti";

//This works
DropDownList1.DataTextField = "id";

DropDownList1.DataSource = l;
DropDownList1.DataBind();

//This works
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate >
<%# Eval("Vidskiptamadur.Heiti")%><br />
</ItemTemplate>
</asp:Repeater>

Code:
My classes

  public class Pontun
    {


        private string id;
        private DateTime dagsetning;
        private Vidskiptamadur vidskiptamadur;
        private Midill midill;

        public virtual Midill Midill
        {
            get { return midill; }
            set { midill = value; }
        }
       

        public virtual Vidskiptamadur Vidskiptamadur
        {
            get { return vidskiptamadur; }
            set { vidskiptamadur = value; }
        }
       
        public virtual string Id
        {
            get { return id; }
            set { id = value; }
        }
       
        public virtual DateTime Dagsetning
        {
            get { return dagsetning; }
            set { dagsetning = value; }
        }

    }

public class Midill
    {
        private string id;
        private string heiti;
        private int tegund;
       

        public virtual string Id
        {
            get { return id; }
            set { id = value; }
        }
       

        public virtual string Heiti
        {
            get { return heiti; }
            set { heiti = value; }
        }
       

        public virtual int Tegund
        {
            get { return tegund; }
            set { tegund = value; }
        }
    }


thanks, Siggi


Last edited by seh@ennemm.is on Fri Oct 27, 2006 9:27 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Please help?
PostPosted: Fri Oct 27, 2006 9:25 am 
Newbie

Joined: Thu Oct 26, 2006 5:34 pm
Posts: 3
anybody?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 28, 2006 2:29 pm 
Beginner
Beginner

Joined: Sat Dec 10, 2005 6:22 pm
Posts: 28
Location: Chicago, IL
Asp.net databinding cannot traverse properties. It can only databind first class citizens.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 28, 2006 2:32 pm 
Newbie

Joined: Thu Oct 26, 2006 5:34 pm
Posts: 3
Is it possible to do this any other way, I'am new to nhibernate how do you usualy do things like this?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 31, 2006 5:10 am 
Beginner
Beginner

Joined: Sat Dec 10, 2005 6:22 pm
Posts: 28
Location: Chicago, IL
Sorry for the delay.

A couple things:

I usually use Data Transfer Objects (DTO) on my views which flatten some of the more complicated association traversals. It also clearly documents what views get what fields and performs pretty good.

Check out Ayende's Blog, he started doing some cool things with DTO's. I added projection support to his Query Generator and he is in the works of cooking up a nice API for strongly typed DTO's.
http://www.ayende.com/Blog/

Secondly, you can use templates with Eval() databinding which works fine.

Third and more cumbersome, you can implement ITypedList on the collection you are returning and implement some propertydescriptors to do this for you behind the scenes.
http://weblogs.asp.net/fbouma/articles/115837.aspx

Fourth, cheeck out Telerik's data grid control. They do the ITypedList for you, so in their datagrid you reference the property Foo_Bar_FirstName which would be Foo.Bar.Firstname. Their controls are cool but a little bloated.
http://www.telerik.com


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.