Its very simple to show the data in GridView from DataBase Table.
First you have to drag gridview from the Data control to your page after that you have writing only the code it will automatically fetch your database table.
or you can progammatically write the code of gridview {
}
in source code:
If you want they appear in different way you can change it yourself you have to only uncheck the auto generated field or maually change in the properties of griedview AutoGenerateColumns="True" to AutoGenerateColumns="False"
code:
You have many option in the gridview properties to change color style and other properties.
I am using here Stored Procedure to Connect with DataBase if you want any help or want to understand how stored procedure created and used in ASP.NET than go to:
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True");
SqlCommand cmd = new SqlCommand("select * from tbl_data", con);
Yogesh KumarRank #2,813 · 504 reputationPosted Sep 14, 2018, 1:40 AM EDT
Radha SinghRank #3,495 · 415 reputationPosted Sep 7, 2018, 1:11 AM EDT
Hardik DeshaniRank #881 · 2.5K reputationPosted Sep 7, 2018, 2:06 AM EDT
Sanwar RanwaRank #23 · 44.7K reputationPosted Sep 7, 2018, 3:31 AM EDT
Mageshwaran RRank #411 · 6.1K reputationPosted Nov 18, 2019, 5:23 AM EST
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts