MCA 401 (Unit 05)
MCA 401 (Unit 05)
MCA 401 (Unit 05)
Figure: ADO.NET
The DataSet Class:
The dataset represents a subset of the database. It does not have a continuous connection to the database.
To update the database a reconnection is required. The DataSet contains DataTable objects and
DataRelation objects. The DataRelation objects represent the relationship between two tables.
The DataTable Class:
The DataTable class represents the tables in the database. It has the following important properties; most
of these properties are read only properties except the PrimaryKey property.
GROUP 1 GROUP 2
1 DetailsView 1 DataList
2 FormView 2 GridView
3 ListView
4 Repeater
Description: Description:
DataList:
The Repeater control is a Data Bind Control, also known as container controls. The Repeater control is
used to display a repeated list of items that are bound to the control. This control may be bound to a
database table, an XML file, or another list of items. It has no built-in layout or styles, so you must
explicitly declare all layout, formatting and style tags within the controls templates.
GridView:
The GridView control is used to display the values of a data source in a table. Each column represents a
field where each row represents a record. It can also display empty data. The GridView control provides
many built-in capabilities that allow the user to sort, update, delete, select and page through items in the
control.
Kushal Johari, Faculty of Computer Applications Page 4
ListView:
The ListView control resembles the GridView control. The only difference between them is that the
ListView control displays data using user-defined templates instead of row fields. Creating your own
templates gives you more flexibility in controlling how the data is displayed. It enables you to bind to
data items that are returned from a data source and display them. The data can be displayed in pages
where you can display items individually, or you can group them.
Repeater:
The Repeater control is used to display a repeated list of items that are bound to the control. This control
may be bound to a database table, an XML file, or another list of items.
namespace DataGrid
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataTable table = new DataTable();
table.Columns.Add("ID");
table.Columns.Add("Name");
table.Columns.Add("Email");
table.Rows.Add("1001", "Kushal Johari", "[email protected]");
table.Rows.Add("1002", "Shefali Singh", "[email protected]");
table.Rows.Add("1003", "Shivangi Ghildiyal", "[email protected]");
table.Rows.Add("1004", "Archana Saxena", "[email protected]");
GridView1.DataSource = table;
GridView1.DataBind();
}
}
}
Output:
It will display the data in table form at runtime: