"appending" column to entity and run time

Posts   
 
    
tmpcl
User
Posts: 20
Joined: 21-Sep-2006
# Posted on: 16-Oct-2006 18:17:00   

I have a collection that I'm binding to a repeater. In the ItemDataBound event I'd like to look up a value based on e.Item.DataItem and then append the single value thats returned to that DataItem so that it can be bound to the repeater.

In other words, given the Type I need to look up and append Hours to that Type and display it on the screen.

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 17-Oct-2006 01:43:39   

Is the looked up value through a related table in the database? If that is the case I would recommend prefetching that entity to retrieve the value. You may also want to take a look at setting up the value as a Field on Related Field. This can be defined in the designer.

tmpcl
User
Posts: 20
Joined: 21-Sep-2006
# Posted on: 17-Oct-2006 17:47:31   

im binding a collection to the repeater and in the ItemDataBound object Im filtering a view. I need to somehow append a vaule from the view to the end of a collection record before databinding.

Is there a better way to do this?



private void rptrGroupList_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
    if ( ( e.Item.ItemType == ListItemType.Item ) || ( e.Item.ItemType == ListItemType.AlternatingItem ) )
    {               
        if ( ( ddlEmployees.SelectedIndex > 0 ) && ( ddlYears.SelectedIndex > 0 ) )
        {
            TimeOffGroupEntity tofeCurrentItem = ((TimeOffGroupEntity) e.Item.DataItem);
                    
            IPredicateExpression peFilter = new PredicateExpression();
            peFilter.Add(EmployeeTimeOffTotalsFields.EmployeeId == int.Parse(ddlEmployees.SelectedValue));
            peFilter.Add(EmployeeTimeOffTotalsFields.Year == int.Parse(ddlYears.SelectedValue));
            peFilter.Add(EmployeeTimeOffTotalsFields.TimeOffGroupId == tofeCurrentItem.TimeOffGroupId);
                    
            tvEmployeeTimeOffTotals.Fill(0, null, false, peFilter);

            if ( tvEmployeeTimeOffTotals.Rows.Count > 0 )
            {       
                {NEED TO DO THE APPEND HERE?}
            }               
        }               
    }
}


tmpcl
User
Posts: 20
Joined: 21-Sep-2006
# Posted on: 17-Oct-2006 23:54:31   

I ended up looping thru the collection and filtering the TypedView on each loop then built a small collection with the data I needed. I then bind the new collection to the repeater.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 18-Oct-2006 08:24:15   

I ended up looping thru the collection and filtering the TypedView on each loop then built a small collection with the data I needed. I then bind the new collection to the repeater.

That's a good and easy way to it. (and that's how I would have done it)