---
title: "Bind Data to GridView in ASP.Net"  
description: "This is my first article. In this article I have shown you how to load a GridView Using Stored Procedure.Stored Procedure:-createprocedure usp_GetEmpl"  
author: "mohan kumar"  
published: 2011-11-03  
updated: 2020-03-04  
canonical: https://www.mindstick.com/articles/802/bind-data-to-gridview-in-asp-dot-net  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# Bind Data to GridView in ASP.Net

This is my first article. In this article I have shown you how to load a GridView Using Stored Procedure.

##### Stored Procedure:-

```
create procedure usp_GetEmployeeDetailsasbeginselect eid,ename,eaddress,ecity,estate from employeeend
```

##### Default.aspx:-

```
 <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs"  Inherits="_Default" %>  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">     <title>A Sample Program Illustrating The Data Retrieval Using Stored Procedure</title></head><body>     <form id="form1" runat="server">     <div>         <asp:GridView ID="GridView1" runat="server">         </asp:GridView>     </div>     </form></body></html>
```

Default.aspx.cs

```
using System;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.Sql;using System.Data.SqlClient;using System.Windows.Forms;  public partial class _Default : System.Web.UI.Page {     SqlConnection conn =  new SqlConnection("Data Source=INNOVA14;uid=sa;pwd=innova;Initial Catalog=Employee");     protected void Page_Load(object sender, EventArgs e)    {         loadmyGridUsingStoredProcedure();    }       public void loadmyGridUsingStoredProcedure()    {         conn.Open();        SqlDataAdapter sda = new  SqlDataAdapter("usp_GetEmployeeDetails", conn);         SqlCommand comm =  new SqlCommand();         comm.CommandType = CommandType.StoredProcedure;         DataTable dt = new DataTable();         sda.Fill(dt);         GridView1.DataSource = dt;         GridView1.DataBind();         conn.Close();    }}
```

---

Original Source: https://www.mindstick.com/articles/802/bind-data-to-gridview-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
