How to Bind DataGrid Values Into a Dataset in VB.NET

A dataset object in Microsoft .NET lets you incorporate several records in a table structure, so you can programmatically display records. You can use the data from a DataGrid to fill a dataset object using the "SetDataBinding" function. Datasets and DataGrid objects work hand-in-hand to query records from a database and display them in a formatted table on a Web page.

Instructions

    • 1

      Click the Windows "Start" button and select "All Programs." Click "Microsoft .NET Framework," then click "Visual Studio." Open your VB.NET project.

    • 2

      Double-click the VB.NET form file in Solution Explorer to open the editor. Double-click the GridView control shown in the form. The VB.NET editor opens.

    • 3

      Create a dataset and fill it with the information in your code's adapter. Type the following code to create the dataset object:

      data = New DataSet()

      adapter.Fill(data)

      Replace "adapter" in the above example with the SQL adapter or object used in the code to retrieve data.

    • 4

      Fill the dataset with the DataGrid data. The following code uses the data in the DataGrid to load the dataset object with records:

      grid.SetDataBinding(data, "Customers")

      Replace "grid" with your own DataGrid name. In this example, the grid's "Customers" list is loaded into the dataset.

Related Searches:

References

Comments

Related Ads

Featured