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 5072 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();

}

0saves
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

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 return Json instead of XML in ASP.NET Web API ?

When you make a call to the ASP.NET Web API action method and notice this in Google Chrome browser ,...

How to Add Web API to existing ASP.NET Web Forms Project ?

In one of the previous posts , we saw how to add the WebAPI to the existing ASP.NET MVC project. Wel...

How to Add Web API to existing ASP.NET MVC Project ?

There are times when you might want to add Web API project to one of your existing ASP.NET MVC proje...