Hi ramco1917,
Please refer below sample.
HTML
<asp:GridView ID="gvEmployees" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" />
<asp:BoundField DataField="Name" HeaderText="Name" />
</Columns>
</asp:GridView>
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
List<Employee> employees = new List<Employee>
{
new Employee() { EmployeeId=1, LastName="Davolio",FirstName ="Nancy" },
new Employee() { EmployeeId=2, LastName="Fuller", FirstName="Andrew" },
new Employee() { EmployeeId=3, LastName="Leverling", FirstName="Janet" }
};
var result = from emp in employees
select new
{
Id = emp.EmployeeId,
Name = string.Format("{0} {1}", emp.FirstName, emp.LastName)
};
gvEmployees.DataSource = result;
gvEmployees.DataBind();
}
}
public class Employee
{
public int EmployeeId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim employees As List(Of Employee) = New List(Of Employee) From {
New Employee() With {
.EmployeeId = 1,
.LastName = "Davolio",
.FirstName = "Nancy"
},
New Employee() With {
.EmployeeId = 2,
.LastName = "Fuller",
.FirstName = "Andrew"
},
New Employee() With {
.EmployeeId = 3,
.LastName = "Leverling",
.FirstName = "Janet"
}
}
Dim result = From emp In employees
Select New With {
.Id = emp.EmployeeId,
.Name = String.Format("{0} {1}", emp.FirstName, emp.LastName)
}
gvEmployees.DataSource = result
gvEmployees.DataBind()
End If
End Sub
Public Class Employee
Public Property EmployeeId As Integer
Public Property FirstName As String
Public Property LastName As String
End Class
Screenshot