Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 98,205 times

Contents

Downloads

Related Categories

Web Forms DataGrid and DataSet Programming - Introduction

Jeff_Louie

Introduction

This is a working C# .NET program that demonstrates how to integrate most of the features of the DataGrid and DataSet in a single project including select, insert, update, delete, confirm delete, sort, filter and page. This is a work in progress and feedback is an important factor in improving this tutorial. Please report any bugs and I will try to fix them.

A few general concepts are presented here and represent my best understanding of how the DataSet and DataGrid works.

The SqlDataAdapter provides a bridge between the DataSet and the data source. Calling Fill, refreshes the data in the DataSet. Calling Update, attempts to commit any changes in the DataSet. The SqlDataAdapter wizard simplifies building of data driven forms by automatically generating UPDATE, INSERT and DELETE statements from your SqlDataAdapter SELECT statement. By default, the UPDATE statement implements an Optimistic Concurrency scheme that looks for an unaltered row on UPDATE.

The DataSet can encapsulate a parent child hierarchy of zero or more data tables. The DataSet also stores its state, storing both the @original values and any new uncommitted values. These original values are used to enforce "Optimistic Concurrency" by searching for unaltered rows on UPDATE. Unlike the DataGrid, the DataSet does _not_ persist itself on post back.

The DataGrid is used to display data in the HTML page. If DataGrid paging is not enabled, the DataGrid will display all of the rows in the appropriate table in the corresponding DataSet. To enable sorting and filtering, the DataGrid is bound to a View, not to the DataSet.

The View is used to sort and filter data in the DataSet before it is passed to the DataGrid using the properties:

view.RowFilter
view.Sort

The data path looks like this:

DataBase --> DataSet --> View --> DataGrid

Comments

  • Untyped dataset

    Posted by vjero on 26 Jan 2006

    How could i do all this with untyped dataset from xml source? (no find methods etc..)
    Vjero

  • sorting in dataview

    Posted by start on 23 Nov 2005

    hi
    hey ppl i m inserting some data manually in a dataview then i m sorting that dta via dataview.sort , sorting is taking place perfectly here but when i embed this data into a word document then ...

  • Sorting ASC or DESC

    Posted by himan_dh on 10 Nov 2005

    hello
    I am converting C#.net code into vb.net code .
    Sorting ASC or DESC is not working .
    while degugging ,code work fine but i think some how dataset is not getting refreshed.
    I have com...

  • sorting ASC or DESC

    Posted by ccharneca on 30 Jun 2005

    Hi.

    I dont know if this only a problem of mine, but when I hit a sort column the DataGridSortCommand happens twice.

    Should this happen? In my case it happens and so all the code in that event do...

  • ResetPageIndex

    Posted by nczimm on 10 Nov 2004

    How do I obtain ResetPageIndex? It is unknown to my installation of .NET or at least to the libraries I am using.