Skip to main content

Practical-24

Various methods of Dataset Object

In this practical, we will learn about the various methods of the Dataset object in ASP.NET.

Step 1: Create a new ASP.NET Web Application project

  1. Open Visual Studio and create a new ASP.NET Web Application project.
  2. Choose the Empty template and click OK.

Step 2: Add a Dataset object to the project

  1. Right-click on the project in the Solution Explorer and select Add -> New Item.
  2. Choose the Dataset template and click Add.
  3. Name the dataset file as "MyDataset.xsd" and click OK.
  4. The dataset file will be added to the project.

Step 3: Design the Dataset

  1. Double-click on the dataset file in the Solution Explorer to open it in the Dataset Designer.
  2. Design the dataset by adding tables, columns, and relationships as per your requirements.
  3. Save the dataset.

Step 4: Use the Dataset object in your code

  1. Open the default.aspx file in the Solution Explorer.
  2. Switch to the Design view.
  3. Drag and drop a GridView control from the Toolbox onto the web form.
  4. Select the GridView control on the web form.
  5. In the Properties window, set the DataSource property to the dataset object.
  6. Set the DataMember property to the table name from the dataset.
  7. Optionally, you can customize the appearance and behavior of the GridView by modifying other properties such as PageSize, AllowSorting, etc.

Step 5: Run the application

  1. Press F5 or click the Start Debugging button to run the application.
  2. The web form will display the data from the dataset in the GridView control.

That's it! You have successfully demonstrated the various methods of the Dataset object in ASP.NET.

Make sure to save your changes and submit this practical in your notebook.