APNSoft.com - Web Controls, components for ASP.NET
 About Us 
 Articles 
 Products
 Downloads 
 Purchase
 Support

DataGrid
Controls Suite 4.5


Overview
Features
Reference Book
Component Parts
Deployment
Binding to Data
Appearance Customization
Templates
Edit Form
Client-side API
Server-side API
Live Demos




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
        


Also, APNSoft DataGrid has the DataSourceID property. This property can be used to refer to actual .NET data source object (SqlDataSource) from which the DataGrid retrieves its list of data items.


[ASPX]
<asp:SqlDataSource id="mySqlDataSource" runat="server" 
    DataSourceMode="DataReader" 
    ConnectionString="..." 
    SelectCommand="..." />

<APNSoft:APNSoftDataGrid id="myDataGrid" runat="server" 
    DataSourceID="mySqlDataSource" />
        





© 2003-2017 APNSoft. All rights reserved.    Terms of use.