How can I bind Data in ASP.NET GridView?


You can easy bind data in ASP.NET. You don't even need to write a single line of code for that. You only need to follow the steps:

1. Fire-up Microsoft Visual Studio IDE. Navigate to File - New -Project. You will find New Project dialog box open. Now select appropriate language from Project Type, Select ASP.NET Web Application from Templates enter name of the project and set the location for it.

Data Binding in ASP.NET Step-1
2. Once you open a new project you will get some default files in Visual Studio Solution Explorer. Open Default.aspx in Design Mode and Add a GridView control from the Toolbox to the Design surface as shown in image below.

Data Binding in ASP.NET Step-2

3. You will find a smart tag on top of the GridView Control, click that. You will see GridView Task window. Click on Choose Data Source Drop Down Control and Select >




Data Binding in ASP.NET Step-3
4. Once you select that you will get Choose a Data Source Type screen, Select DataBase and click Next.


Data Binding in ASP.NET Step-4
5. Now click New Connection button and Select Microsoft SQL Server and Click Continue button and then Click Next button.



Data Binding in ASP.NET Step-5
6. You need to select your SQL Server Database name in Server Name location. Once you select  the name that will populate all the database in Select or enter a database name: field. Select one database and Click on Test Connection button at you bottom. You will get a confirmation that Test Connection Succeeded. Click OK button twice.



Data Binding in ASP.NET Step-6
7. Now click Next button two time. You will get the following image. Select the table and then the column as shown in image below. Click Next

Data Binding in ASP.NET Step-7
8. You will get the Test Query screen. Now you have the query  just click Test Query button to check you query. To test you query is correct or not. Then Click Finish button.

Data Binding in ASP.NET Step-8
9. Now Run you application in Visual Studio to see the output.

Data Binding in ASP.NET Step-9

No comments:

Post a Comment

Recent Posts