You can use value binding to TemplateField. Inside, you can use any type of Bind control suitable for your data type. Here is an example:
<asp:GridView ID="gvEmployees" runat="server" AllowSorting="true" AutoGenerateColumns="false" DataKeyNames="ID" DataSourceID="godsCourses">
<Columns>
<asp:TemplateField HeaderText="Job Title">
<ItemTemplate>
<asp:Literal ID="hlProgram" runat="server" Text='<%# Bind("JobTitle.Name") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
I used JobTitle.Name, believing that it JobTitleIDis associated with an object JobTitle.
source
share