Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Avid Listener
Posts: 17
Registered: ‎04-03-2009

HOw to return Filed value using IRepository?

I want to change the label text based on a fileld value(not the main entity in the form). How do I do that? Can I color this label?

 

 public static void OnLoadAccountDetailStep( IAccountDetails form, EventArgs args, out object result)

{

// TODO: Complete business rule implementation

IRepository<IEsiSofcm> rep = EntityFactory.GetRepository<IEsiSofcm>();

IQueryable qry = (IQueryable)rep;

IExpressionFactory ef = qry.GetExpressionFactory();

ICriteria criteria = qry.CreateCriteria();

criteria.Add(ef.Eq(
"CUSTOMER_ID", "ASCLEP2"));

result = criteria.List<IEsiSofcm>();

 

 

form.lblCreditHold.Text = "TEST";

 

//what I want is

form.lblCreditHold.Text = result.Customer_Status;

}

 

Thanks

New Member
Posts: 1
Registered: ‎10-22-2009

Re: HOw to return Filed value using IRepository?

Hi Veronka,

 

Your variable 'result' is of type object, you have to cast it first to the datatype you are returning from you query in order to access its properties.

 

Something like this (be aware that it will work if you return a unique element) however in your code you are returning a list so you will have to select the item in the list that you whant to use the value from:

 

form.lblCreditHold.Text = ((IEsiSofcm)result).Customer_Status;

 

And yes regarding your second question you can change the properties of the label using its NativeControl

 

System.Web.Controls.Label customLabel = (System.Web.Controls.Label)form.lblCreditHold.NativeControl

 

this way you can access all label properties.

Highlighted
Bronze Super Contributor
Posts: 204
Registered: ‎03-10-2009

Re: HOw to return Filed value using IRepository?

Also since result is a list object you might have to do this to get the first item in this object

result[0]


Sr. Sales Engineer
Gene Arnold