---
title: "how v insert data into table  and display into gridview in aspx.cs file with out using wizard"  
description: "how v insert data into table  and display into gridview in aspx.cs file with out using wizard"  
author: "Pawan kumar"  
published: 2011-02-21  
updated: 2011-02-22  
canonical: https://www.mindstick.com/forum/172/how-v-insert-data-into-table-and-display-into-gridview-in-aspx-cs-file-with-out-using-wizard  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# how v insert data into table  and display into gridview in aspx.cs file with out using wizard



## Replies

### Reply by Anonymous User

I can not understand your question correctly. How do you entered data in table. By using [sql management](https://www.mindstick.com/forum/159668/what-is-the-difference-between-sql-server-and-sql-management-studio) window or any other. Well Here I can show you a method to [insert data](https://www.mindstick.com/forum/33964/insert-data-in-datagridview-from-text-box-c-sharp) in table by using [sql command](https://www.mindstick.com/blog/142/categorize-sql-commands-in-sql-server) management window than programmatically display that data in [grid view](https://www.mindstick.com/forum/477/grid-view).

**Write down following commands to insert [data in sql](https://www.mindstick.com/articles/12937/how-to-import-excel-data-in-sql-server-2014) management window**

Insert into Student values(‘S0001’,’Jon’,’Lues’,21,’New Verginia’)

**Method to [display data](https://www.mindstick.com/forum/160249/what-is-the-role-of-the-display-data-annotation-to-display-name-for-a-model-property-in-dot-net-core) in grid view**

Drag-Drop Grid view control on [aspx page](https://www.mindstick.com/forum/218/how-do-i-create-an-aspx-page-that-periodically-refreshes-itself) at [design view](https://answers.mindstick.com/qa/94814/design-view-is-not-getting-displayed-in-my-android-studio-what-should-i-do) then [double click](https://www.mindstick.com/forum/155692/what-is-dfp-double-click-for-publisher) the page and at the load event of page write down following code

```
public void loadData() {         SqlConnection con = new SqlConnection();         con.ConnectionString = "Pass connection string of your sql server.";         SqlCommand cmd = new SqlCommand("select * from Student", con);         con.Open();         SqlDataReader dr = cmd.ExecuteReader();         DataTable dt = new DataTable();         dt.Load(dr);         GridView1.DataSource = dt.DefaultView;         GridView1.DataBind();         con.Close(); }
```

One thing important to use [SqlConnection](https://www.mindstick.com/forum/1209/sqlconnection-sqlcommand-sqldatareader-idisposable) object and DataTable object please use two namespace first one is using System.Data and second one is System.Data.SqlClient.


---

Original Source: https://www.mindstick.com/forum/172/how-v-insert-data-into-table-and-display-into-gridview-in-aspx-cs-file-with-out-using-wizard

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
