Bind Data to Grid in ADO.NET

Assalamualaykum Wr Br… Today we explore how data can be populated on GridView…
Let us first we understand what is GridView?
To be very specific, GridView is a Control which is highly used to display data in tabular format. In detail,
The GridView control is the successor to the DataGrid and extends it in a number of ways. With this GridView control, you could display an entire collection of data, easily add sorting and paging, and perform inline editing. In addition to just displaying data, the GridView can be used to edit and delete the displayed data as well. Now lets start our practical session, where I import SqlClient,OracleClient or OledbClient dlls in my project and in addition to hard coding C# standard as using System.Data.SqlClient; or VB Standard as imports System.Data.SqlClient
When you want to connect to Oracle Database, you need to download Oracle.DataAccess dll which is available @ http://www.oracle.com/technetwork/topics/dotnet/downloads/net-downloads-160392.html which available in ODAC package. Please follow the Design Pattern as shown:

grid_design
The respective C#.NET code for Button click which populates data in GridView is shown:
grid_codeUpon Executing the above project the following output appears after button click:
output_grid
Please note that I used DataReader which is Disconnected data architecture which we deal it in coming posts…Hope you might enjoy this post…Till Then have a good day…

Jazakallah khair…

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s