Binding a DataSet to a DataGrid in ASP.Net
Mar
13
Written by:
3/13/2009 3:33 PM
Binding a DataSet to a DataGrid in ASP.Net
I am in the process of enhancing the functionality of an ASP.Net application that I inherited and today I needed to display a grid of related data below an entry form on a page. Some of the functionality was present on a different page following the style the original programmer implemented. A database function to return a Datasource did not exist within the data class so that was my first step. I found this great code below showing the basic syntax of binding a dataset to a datagrid in ASP.Net which was helpful.
Imports System.Data
Imports System.Data.OleDb
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' create a connection string
Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Northwind.mdb"
Dim myConnection As OleDbConnection = New OleDbConnection
myConnection.ConnectionString = connString
' create a data adapter
Dim da As OleDbDataAdapter = New OleDbDataAdapter("Select * from Customers", myConnection)
' create a new dataset
Dim ds As DataSet = New DataSet
' fill dataset
da.Fill(ds, "Customers")
' Attach DataSet to DataGrid
DataGrid1.DataSource = ds.DefaultViewManager
End Sub
4 comment(s) so far...
Re: Binding a DataSet to a DataGrid in ASP.Net
Thanks very much for this post! Was very helpful for me!
By Mustang Ford on
3/16/2009 12:54 PM
|
Re: Binding a DataSet to a DataGrid in ASP.Net
I appreciate the fact that you are letting us see the previews
By How to start a nursing agency on
3/17/2009 10:06 AM
|
Re: Binding a DataSet to a DataGrid in ASP.Net
thanks
By Web tasarim on
3/26/2009 9:34 AM
|
Re: Binding a DataSet to a DataGrid in ASP.Net
Define in the Asp .net because in the post described the all the features in the post how to work and used in this technology so that can be able to understand properly.
By Loftisolering on
12/22/2011 5:23 AM
|