What is Datatable
A datatable is an
object in the .NET Framework System.Data library that represents an in-memory
list of rows and columns of data.
Many .NET Controls
can use datatables for their input (such as grids).
A datatable can be
created and populated programmatically, but more often a DataTable is retrieved
as part of a database query.
DataSource Controls
The ASP.Net DataSource controls allow working with different types of
data sources such as databases, or XML document files. ASP.Net includes
various data source controls that can be added to web pages using their
declarative code block. The DataSource controls enable to expose data from
backend data stores such as SQL database, Oracle database, MS Access database,
middle-tier business objects or any XML document file. In ASP.Net you can bind
the data source controls directly to the databound UI controls without writing
any server side code for database connectivity or other CRUD (Create, Read, Update and Delete)
methods. The DataSource controls support almost all necessary features,
which are required to work with any kind of data store, such as insert, update,
delete, sorting, paging and caching data. A data source control loaded with all
these capabilities can be plugged to any databound UI control to take the
advantage of automated functionality without writing any single line of code.
The following topics provide the more detailed information about the
properties, events, and syntax of ASP.Net DataSource Web Server controls:
List of
Tutorials
AccessDataSource Control
The ASP.Net AccessDataSource web server control is a data source
control that enables to connect to Microsoft Access Database. It derives from SqlDataSource control that establishes a connection
between .mdb file of Microsoft Access Database and
provides the ability of filtering, sorting and paging the data fetched from the
database. The ConnectionString property inherited from SqlDataSource
class has been replaced with DataFileproperty in
AccessDataSource control. The DataFile property accepts a path to an MDB file
instead of complete connection string. The AccessDataSource control uses the System.Data.OleDb provider to connect to Access Database. It
uses the Microsoft.Jet.OLEDB.4.0
OLE DB provider to establish a successful connection
between the control and the database.
Note: For binding the AccessDataSource control to
any DataBound control you can set the value of DataSourceIDproperty
of DataBound control equal to the ID property of AccessDataSource control.
ObjectDataSource Control
The ASP.Net ObjectDataSource control enables to work with
underlying data stores of different types such as SQL databases or XML. The
majority of ASP.Net Data Source controls support only two-tiered architecture
of application where the presentation layer interacts directly with data access
layer. Whereas, the ObjectDataSource control allows to structure the
application using three-tiered architecture also, that includes data access
layer, business logic layer and presentation layer. In this kind of
three-tiered architecture the business logic layer communicates with data
access layer and returns the data information retrieved from back end database
to the presentation layer. The ObjectDataSource control enables a declarative
databinding model that performs according to the specified type of Data Access
or Business Logic component class. It uses the specified methods for each of
Select, Update, Insert and Delete to perform the associated data operations.
The ObjectDataSource control is sometimes
called a middle-tier for encapsulating the database queries.
Note: For binding the ObjectDataSource control to
any DataBound control you can set the value of DataSourceIDproperty
of DataBound control equal to the ID property of ObjectDataSource control.
SiteMapDataSource Control
The ASP.Net SiteMapDataSource control is a data source web server
control that enables to bind the hierarchical site map data to other databound
controls. It provides the ability to display the site navigation data on the
web pages of an application using navigation controls such as TreeView or Menu control.
Note: For binding the SiteMapDataSource control
to any DataBound control you can set the value of DataSourceIDproperty
of DataBound control equal to the ID property of SiteMapDataSource control.
XmlDataSource Control
The ASP.Net XmlDataSource control provides a web server data
source control that enables to declaratively connect to XML
documents or
files and bind them to any databound control. It represents the hierarchical
data source that can be bound to server controls such as TreeView or Menu, to parse hierarchy of nodes and present
them in the form applied structure or layout defined in the server control. The
XmlDataSource control can also be bound to DataBound controls such as GridView,
DataList or Repeater control to display the XML data in tabular form of
customized layout form.
You can simply specify the path to XML file
and a valid XPath to read the nodes of an underlying XML document using
XmlDataSource control.
Note: For binding the XmlDataSource control to
any DataBound control you can set the value of DataSourceIDproperty
of DataBound control equal to the ID property of XmlDataSource control.
SqlDataSource Control
The ASP.Net SqlDataSource control enables to connect to ADO.Net
SQL database provider, such as SQL, OLEDB, ODBC, or Oracle. It has all the
basic capabilities required for data operations such as select, insert, update,
delete and sort which provide an automatic functionality to the data bound
controls. The SqlDataSource control replaces the traditional way of
initializing the connection and commands in the server side code of a web page.
It allows to specify the connection string and database queries directly as
properties of data source control having no middle-tier layer between data
access and presentation layers. It uses the two-tier model to access the data
and display it using any data bound control declaratively.
Note: For binding the SqlDataSource control to any DataBound control
you can set the value of DataSourceIDproperty
of DataBound control equal to the ID property of SqlDataSource control.
Syntax
1. <asp:SqlDataSource ID="SqlDataSource1" runat="server">
2. <DeleteParameters>
3. <%-- Parameters Collection --%>
4. <%-- Set of Common Parameter templates --%>
5. <asp:ControlParameter />
6. <asp:CookieParameter />
7. <asp:DynamicControlParameter />
8. <asp:DynamicQueryStringParameter />
9. <asp:FormParameter />
10. <asp:Parameter />
11. <asp:ProfileParameter />
12. <asp:QueryStringParameter />
13. <asp:RouteParameter />
14. <asp:SessionParameter />
15. </DeleteParameters>
16. <FilterParameters>
17. <%-- Parameters Collection --%>
18. <%-- Set of Common Parameter templates --%>
19. </FilterParameters>
20. <InsertParameters>
21. <%-- Parameters Collection --%>
22. <%-- Set of Common Parameter templates --%>
23. </InsertParameters>
24. <SelectParameters>
25. <%-- Parameters Collection --%>
26. <%-- Set of Common Parameter templates --%>
27. </SelectParameters>
28. <UpdateParameters>
29. <%-- Parameters Collection --%>
30. <%-- Set of Common Parameter templates --%>
31. </UpdateParameters>
32. </asp:SqlDataSource>
SqlDataSource: Properties
Property
|
Description
|
CacheDuration
|
enables to get
or set the time in seconds to specify the cache time length for storing the
data retrieved by the Select method.
|
CacheExpirationPolicy
|
enables to get
or set the cache expiration behavior combined with the cache duration
property.
|
CacheKeyDependency
|
enables to get
or set the user-defined cache key dependency that can be used with multiple
cache enabled controls. All the data cache objects linked to same cache key
expire along with the expiration of cache key.
|
CancelSelectOnNullParameter
|
enables to get
or set a Boolean value that indicates whether to
cancel the operation if any of the parameter in SelectParameters collection
evaluates to null.
|
ConflictDetection
|
enables to get
or set the value indicating how data source control performs the update and
delete operation when data in a row changes during the time of
operation.
|
ConnectionString
|
enables to get
or set the ADO.Net provider specific database connection string that is
used to connect to SQL database.
|
DataSourceMode
|
enables to get
or set the data retrieval mode to fetch the data.
|
DeleteCommand
|
enables to get
or set the SQL command text or stored procedure name that the
control uses to perform the delete operation.
|
DeleteCommandType
|
enables to get
or set the value indicating whether the delete command type is a SQL string
or name of stored procedure.
|
DeleteParameters
|
enables to get
the collection of parameters that are used by theDeleteCommand property.
|
EnableCaching
|
enables to get
or set a Boolean value that indicates whether to
enable the caching feature of data source control or not.
|
FilterExpression
|
enables to get
or set the filtering expressions for Select method.
|
FilterParameters
|
enabels to get
the collection of parameters that are used by the FilterExpression property.
|
InsertCommand
|
enables to get
or set the SQL command text or stored procedure name that the
control uses to perform the insert operation.
|
InsertCommandType
|
enables to get
or set the value indicating whether the insert command type is a SQL string
or name of stored procedure.
|
InsertParameters
|
enables to get
the collection of parameters that are used by theInsertCommand property.
|
OldValuesParameterFormatString
|
enables to get
or set the format string applied to parameter names for original values that
are passed to delete or update method.
|
ProviderName
|
enables to get
or set the name of .Net data provider that allows the SqlDataSource
control to connect to SQL Database.
|
SelectCommand
|
enables to get
or set the SQL command text or stored procedure name that the
control uses to perform the select operation.
|
SelectCommandType
|
enables to get
or set the value indicating whether the select command type is a SQL string
or name of stored procedure.
|
SelectParameters
|
enables to get
the collection of parameters that are used by theSelectCommand property.
|
SortParameterName
|
enables to get
or set the name of stored procedure parameter used to sort the data retrieved
using a stored procedure.
|
SqlCacheDependency
|
enables to get
or set semi-colon delimited string that indicates which databases or tables
to use for the Microsoft SQL Server cache dependency.
|
UpdateCommand
|
enables to get
or set the SQL command text or stored procedure name that the
control uses to perform the update operation.
|
UpdateCommandType
|
enables to get
or set the value indicating whether the update command type is a SQL
string or name of stored procedure.
|
UpdateParameters
|
enables to get
the collection of parameters that are used by theUpdateCommand property.
|
Properties: inherited
from DataSourceControl
|
|
ClientID
|
enables to get
the identifier generated for server control by ASP.Net.
|
Controls
|
enables to get
the collection of child controls.
|
EnableTheming
|
enables to get
or set a Boolean value indicating whether to apply
themes to this control or not.
|
SkinID
|
enables to get
or set the skin to apply to the DataSourceControl.
|
Visible
|
enables to get
or set a Boolean value
indicating whether to show the control or not.
|
SqlDataSource: Events
Event
|
Description
|
Deleted
|
occurs after
performing the delete operation.
|
Deleting
|
occurs before
performing the delete operation.
|
Filtering
|
occurs before
performing the filter operation.
|
Inserted
|
occurs after
performing the insert operation.
|
Inserting
|
occurs before
performing the insert operation.
|
Selected
|
occurs after
performing the select operation.
|
Selecting
|
occurs before
performing the select operation.
|
Updated
|
occurs after
performing the update operation.
|
Updating
|
occurs before
performing the update operation.
|
Standard Properties and Events
Control Standard
Properties
|
ID,
EnableViewState, NamingContainer, BindingContainer, Page, TemplateControl,
Parent, TemplateSourceDirectory, AppRelativeTemplateSourceDirectory, Site,
UniqueID
|
Control Standard Events
|
Disposed,
DataBinding, Init, Load, PreRender, Unload
|
No comments:
Post a Comment