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
Fast and Free Expedited Shipping on orders over $59 offer applies to Bookbyte inventory only - 160x600 banner

Recent Comments

Minimize
Re: Three Benefits to Using a Royalty-Free Image on Your Website or Blog
I also prefer to use royalty-free images. They give more credibility in your site or blog posts.
Re: Websites vs. Facebook Pages (Infographic)
Internet can be very useful for small business to market them self, there is always some free way to reach your audience via Internet.
Re: Is Keyword Density Still Important For On Page SEO
The search engines hadn’t quite caught up yet. As a result, it wasn’t uncommon to see sites rank highly when their content read something like this.that they follow SEO best practices than you will by trying to figure out a way to get your keywords into your page content another one or two times.
Re: Websites vs. Facebook Pages (Infographic)
Very interesting topic, infographics was a new concept for me, will definitely use it.
Re: Reducing Small Business Blues
Running a business is tough and you are right, most of the time you are the core aspect of each area of a business. I don't think I could handle doing my own accounting, like you I am too terrible with numbers!

u comment, i follow