DataBinding with GridView Control :
Step 1: Create and Add a new SQL Server Database to your project by right-clicking on the App_Data Folder in the solution Explorer > Choose Add New Item > Choose SQL Server Database.
Step 2 : Create a database in the App_Data folder called Employee.mdf. Columns : empif, empname, empphone, empemail, empcity.
Step 3: Then right-click on the employee table- Opt show data and add some records to this table.
Step 4: Access the database in ASP.NET page.
Start by adding a SqlDataSource control to your emp.aspx page From the Design view, the SqlDataSource control contains a "smart tag" that lists its common functionality.
Step 5 : Choose a Data Connection - This screen has a drop-down list of those database in the App_Data folder. There's also a New Connection button that you can click if you want to connect to a new database. Choose the employee.mdf option from the drop=down list.
Step 6 : Configure the SELECT Statement
Step 7: Test Query
Step 8: Display the data from the database on the web page's grid view.
Add a data control - Let's use the GridView control, which is also found in the "Data" section of the Toolbox. Drag a Gridview control onto your ASP.NET page's.
Step 9: Run the .aspx file to see the below output
0 Comments:
Post a Comment