-->
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.  [ 3 posts ] 
Author Message
 Post subject: nhibernate binding into a gridview
PostPosted: Thu Jun 04, 2009 6:15 pm 
Newbie

Joined: Tue Jun 02, 2009 1:14 pm
Posts: 1
I need an example of code where I can bind data into a gridview

this is my code where I load my entire data from sql

just want an example to start

Code:
   public IList<T> loadEntity<T>() where T : class
        {
            IList<T> data = new List<T>();
            ISessionFactory factory = null;
            ISession session = null;
            ITransaction transaction = null;
            try
            {
                factory = cfg.BuildSessionFactory();
                session = factory.OpenSession();
                transaction = session.BeginTransaction();
                data = session.CreateCriteria(typeof(T)).List<T>();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
                transaction.Rollback();
                if (transaction != null) transaction.Rollback();
            }
            finally
            {
                if (transaction != null) transaction.Dispose();
                session.Close();
                factory.Close();
            }
            return (data);
        }


Top
 Profile  
 
 Post subject: Re: nhibernate binding into a gridview
PostPosted: Mon Jun 08, 2009 11:33 am 
Newbie

Joined: Sat May 30, 2009 11:42 am
Posts: 15
Datagridview.DataSource = LoadEntity<YourObject>();


Top
 Profile  
 
 Post subject: Re: nhibernate binding into a gridview
PostPosted: Sat Jul 18, 2009 2:22 am 
Newbie

Joined: Sat Feb 17, 2007 5:29 am
Posts: 2
But with that solution, you won't have the ability to sort the grid when clicking on the header...

Does anyone have the solution ?

Thanks.


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