Asp.net GridView example using C#

Published on September 1, 2013 by abundantcode

Filed under ASP.NET

Last modified September 1, 2013

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 1.3 (3 votes)

This article have been viewed 6392 times

Below is a sample code snippet for Asp.net GridView example using C#. The code snippet shows how to populate the GridView with a List of Employees.

Asp.net GridView example using C#

ASP.NET WebForms

<asp:GridView ID="GridView1" runat="server">

</asp:GridView>

C#

protected void Page_Load(object sender, EventArgs e)

{

List<Employee> employees = new List<Employee>();

employees.Add(new Employee { Name = "Test1", Designtaion = "Software Engineer" });

employees.Add(new Employee { Name = "Test2", Designtaion = "Architect" });

employees.Add(new Employee { Name = "Test3", Designtaion = "Vice President" });

GridView1.DataSource = employees;

GridView1.DataBind();

}

1 Comment

  1. gopal

    please send me a e-auction site in asp.net

    March 6, 2014 - 3:20 pm – Reply

Leave a Comment


x

You might be Interested in these Posts

How to download a file from a URL using C#?

You can use the WebClient class in C# to download a file. How to download a file from a URL using C...

How to read connection string from web.config in ASP.NET and C# ?

Here's a sample code snippet demonstrating how to get the connection string from your ASP.NET web.co...

How to Create an Empty array without defining the size in C# ?

When we create an array in C# , we tend to define the size of the array as shown below. String[] st...