---
title: "Data Grid View"  
description: "To create DataGridView  first of all we need to insert DataGridView tool from toolbox.Now, once the DataGrid  is inserted we need to display data in i"  
author: "Uttam Misra"  
published: 2010-07-25  
updated: 2020-03-04  
canonical: https://www.mindstick.com/articles/53/data-grid-view  
category: "ado.net"  
tags: ["ado.net"]  
reading_time: 1 minute  

---

# Data Grid View

To create DataGridView first of all we need to insert DataGridView tool from

toolbox.

![Data Grid View](https://www.mindstick.com/mindstickarticle/37ced6f5-fa75-498d-9eb9-681993fe23be/images/0795f17b-7b09-4acc-896c-3608de73f706.png)

Now, once the DataGrid is inserted we need to display data in it. To display data we

need to set its data source data table.

##### Example

```
           try            {            string strConnection= "Server=abc\\SQLEXPRESs;Database=Employee;Trusted_Connection=True";            SqlConnection con = new SqlConnection(strConnection);            con.Open();            SqlDataAdapter da = new SqlDataAdapter("select * from employee", con);            DataSet ds = new DataSet();            da.Fill(ds, "Employee");            DataTable dt = ds.Tables["Employee"];            dgRecord.DataSource= dt;          //setting datasource of datagrid to a table of database ‘employee’            }            catch (Exception ex)            {                MessageBox.Show(ex.Message);            }
```

##### \
Here dgRecord is the name of DataGrid.

![Data Grid View](https://www.mindstick.com/mindstickarticle/37ced6f5-fa75-498d-9eb9-681993fe23be/images/1f94e87e-db04-435e-ad2e-6b3eaee94e2a.png)**\**

---

Original Source: https://www.mindstick.com/articles/53/data-grid-view

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
