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.
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
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
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.