Hi ps222,
Please take reference to the below code and correct your code.
Database
For this example I have used of NorthWind database that you can download using the link given below.
Download Northwind Database
HTML
<asp:GridView ID="gvEmployees" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="EmployeeName" HeaderText="Name" />
<asp:BoundField DataField="Country" HeaderText="Country" />
</Columns>
</asp:GridView>
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
var id = 1;
NorthwindEntities entity = new NorthwindEntities();
var result = entity.Employees
.Where(X => X.EmployeeID == id)
.Select(emp =>
new
{
EmployeeName = emp.FirstName + " " + emp.LastName,
Country = emp.Country
}).ToList();
this.gvEmployees.DataSource = result;
this.gvEmployees.DataBind();
}
Screenshot
