You are here:   Home
Register   |  Login

Captured Technology - Blog

Minimize

Binding a DataSet to a DataGrid in ASP.Net

Mar 13

Written by:
3/13/2009 3:33 PM  RssIcon

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

Tags:
Categories:

4 comment(s) so far...


Gravatar

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
Gravatar

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
Gravatar

Re: Binding a DataSet to a DataGrid in ASP.Net

thanks

By Web tasarim on   3/26/2009 9:34 AM
Gravatar

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

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
CAPTCHA image
Enter the code shown above in the box below
Add Comment   Cancel 

FaceBook

Minimize

Mobile Version

Minimize
Add CapturedTech - Technology Mippin widget

Translate

Minimize

Sponsors

Minimize
Design your own Fandango Bucks gift card!

Recent Comments

Minimize
Re: Three Benefits to Using a Royalty-Free Image on Your Website or Blog
Don't pay for royalty free images. They are free after all! I offer links to 96 websites that have tens of thousands (maybe even hundreds of thousands) of absolutely free images, including ones for commercial use! All you need to do is subscribe to my blog at www.davesinternetmarketing.info/royalty-free-images-free-for-commercial-use/
Re: Buzzom Offers Featured User Options
This is when discovered this great new way to grow your follow list. You can pay between $10 and $100 for the number of times you want to app ar at the top of the list.
Re: Microsoft Test Bounties
I had spent a good deal of my time looking for someone to explain this subject clearly and I have really enjoyed reading your blog posts and I collected a lot of interesting things as well as I done a research on the subject and learn most peoples will agree with your blog.
Re: 10 Ways to Source Great Sales Leads
Hoovers.com, that have contact information for tens of millions of businesses. If necessary, you can work with these companies' research teams to order lists specifically tailored to your organization's sales needs.
Re: Microsoft Test Bounties
To find bugs and showing it to microsoft is quite admirable. Keep blogging more i will appreciate.

u comment, i follow