I can not understand your question correctly. How do you entered data in table. By using sql management window or any other. Well Here I can show you a method to insert data in table by using sql command management window than programmatically display that data in grid view.
Write down following commands to insert data in sql management window
Insert into Student values(‘S0001’,’Jon’,’Lues’,21,’New Verginia’)
Method to display data in grid view
Drag-Drop Grid view control on aspx page at design view then double click 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 object and DataTable object please use two namespace first one is using System.Data and second one is System.Data.SqlClient.
Liked By
Write Answer
how v insert data into table and display into gridview in aspx.cs file with out using wizard
Join MindStick Community
You have need login or register for voting of answers or question.
Anonymous User
22-Feb-2011I can not understand your question correctly. How do you entered data in table. By using sql management window or any other. Well Here I can show you a method to insert data in table by using sql command management window than programmatically display that data in grid view.
Write down following commands to insert data in sql management window
Insert into Student values(‘S0001’,’Jon’,’Lues’,21,’New Verginia’)
Method to display data in grid view
Drag-Drop Grid view control on aspx page at design view then double click the page and at the load event of page write down following code
One thing important to use SqlConnection object and DataTable object please use two namespace first one is using System.Data and second one is System.Data.SqlClient.