-->
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.  [ 2 posts ] 
Author Message
 Post subject: Binding ISQLQuery results to a DropDownList DataSource?
PostPosted: Thu Mar 26, 2009 4:31 pm 
Beginner
Beginner

Joined: Mon Feb 04, 2008 1:48 pm
Posts: 30
I understand that the List() method returns an IList of Object[]. How can I easly bind this to a drop down list data source?

Code:

            ISQLQuery query;
            string sql = "SELECT t.* " +
                         "FROM CompanyTheme ct, Theme t " +
                         "WHERE ct.ThemeID = t.ThemeID AND ct.CompanyID = :companyID";

            query = Session.CreateSQLQuery(sql)
                .AddScalar("ThemeID", NHibernateUtil.Int32)
                .AddScalar("Name", NHibernateUtil.String)
                .AddScalar("Folder", NHibernateUtil.String);

IList results = query.SetInt32("companyID", companyID).List();

ddl.DataTextField = ;
ddl.DataValueField = ;
ddl.DataSource = results;


Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 26, 2009 11:43 pm 
Beginner
Beginner

Joined: Mon Feb 04, 2008 1:48 pm
Posts: 30
Is there anything more elegant than this?

Code:
foreach (object[] row in results)
        {
            ddl.Items.Add(new ListItem(row[1].ToString(), row[2].ToString()));
        }


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.