|
DataGrid
Controls Suite 4.1 |
 | Overview |
 | Features |
 | Reference Book |
 | Live Demos |
|  | Populating with Data |
|  | Columns |
|  | Rows |
|  | Appearance & Layout |
|  | Behavior |
|  | Bottom Bar |
|  | Application scenarios |
| |  | Master/Detail Grids |
| |  | CheckBoxes |
| |  | DropDowns |
| |  | Images |
| |  | Update Panel |
|
APNSoft DataGrid displays data obtained from a database or other data source. The data is presented in tabular format. To bind to a data source, set the DataSource property and call the DataBind() method. DataGrid supports different data sources: DataView, DataTable, DataSet, DataReader and any object that implements IEnumerable interface.
[C#]
protected void Page_Load(object sender, EventArgs e)
{
//Define SQL query
string SqlQuery = @"SELECT CustomerID, CompanyName, ContactName FROM Customers";
//Get DataTable
DataTable myDataSource = GetDataTable(SqlQuery);
//Set the data source
myDataGrid.KeyFieldName = "CustomerID";
myDataGrid.DataSource = myDataSource;
myDataGrid.DataBind();
}
[VB.NET]
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
'Define SQL query
Dim SqlQuery As String = "SELECT CustomerID, CompanyName, ContactName FROM Customers"
'Get DataTable (MS Access Database)
Dim myDataSource As DataTable = GetDataTable(SqlQuery)
'Set the data source
myDataGrid.KeyFieldName = "CustomerID"
myDataGrid.DataSource = myDataSource
myDataGrid.DataBind()
End Sub
The full code samples are available in Live Demos.
|