-->
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: How to fetch values in textbox and grid by firing one query
PostPosted: Sat May 19, 2007 5:48 am 
Newbie

Joined: Sat Apr 21, 2007 2:12 am
Posts: 16
Hi All
I want to fetch values in various controls placed on the form through one query only.
Right now i am able to fetch values in grid through nhibernate through this code


//************************************
string query = "From Customer c where c.CompanyId like '" + companyId + "'";


ISession session = null;

try
{
session = LogInForm.NHSession;
this.grid1.DataSource = session.CreateQuery(query).List();
}
finally
{
session.Close();
}
//*************************************

and it is working fine. But i want that by firing one query only all the controls on form like textbox etx should be filled.

How can i do it...Pls help...

Regards,
Gaurav


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 19, 2007 11:58 am 
Regular
Regular

Joined: Wed Apr 25, 2007 4:18 am
Posts: 51
Location: Belarus, Gomel
Hi Gaurav!

You may use BindingSource on your form - and bing grids, listboxes, textboxes and other controls to it.

Or you may store retreived list in some other place (the most straightforward but not the best is field/propertry of this form itself) and initialize DataSource of your controls with this "stored" value, while retreiving data only once.

_________________
WBR, Igor


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 21, 2007 1:33 am 
Newbie

Joined: Sat Apr 21, 2007 2:12 am
Posts: 16
Hi Igor
Thanks for the reply. I would really appreciate if u could give me an example/code...
Well, I tried binding my controls to the class with this code

textBox1.DataBindings.Add(new Binding("Text",session.CreateQuery(query).List(),"ExampleApplication.Customer.CompanyName"));

but it throws me this error..
Child list for field ExampleApplication cannot be created

How to use DataBindings with control? I want that when i select some value in a combo box..a query should be fired and data should get filled in various controls on that form.
Please help...

Thanks

Gaurav


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.