Assuming you just want to display the
first rate from the list, add a new property to your
Employee
class:
public class Employee : StandardMaster
{
...
public decimal? FirstRate
{
get
{
if (EmployeeToCountryRate == null) return null;
if (EmployeeToCountryRate.Count == 0) return null;
return EmployeeToCountryRate[0].RATE;
}
}
}
Then you can bind your
TextBox
to the new property:
<asp:TextBox ID="cost" runat="server" MaxLength="11" Value='<%# Eval("EMPLOYEE_ID.FirstRate") %>' Enabled="false" />
To display a single rate which matches a specific condition, then update the property:
public decimal? FirstRate
{
get
{
if (EmployeeToCountryRate == null) return null;
var theRate = EmployeeToCountryRate.FirstOrDefault(x => ???);
return theRate == null ? null : theRate.RATE;
}
}
If you want to display a list of
all the rates, then you'll need a nested data-bound control. For example:
<asp:TemplateField HeaderText="Employee Cost(per hour)">
<ItemTemplate>
<asp:ListView runat="server" DataSource='<%# Eval("EMPLOYEE_ID.EmployeeToCountryRate") %>'>
<LayoutTemplate>
<ul>
<li id="itemPlaceholder" runat="server" />
</ul>
</LayoutTemplate>
<ItemTemplate>
<li>
<asp:Literal runat="server" mode="encode"
Text='<%# Eval("COUNTRY_ID.Name") %>'
/>
=
<asp:Literal runat="server" mode="encode"
Text='<%# Eval("RATE", "{0:C}") %>'
/>
</li>
</ItemTemplate>
</asp:ListView>
</ItemTemplate>
</asp:TemplateField>