In this section, we learn about ASP.NET data listing and data management tools.
The ASP.NET DataList control is a Databound server-side control that works as a container for data items.
It is used to display data into a list format to the web pages.
It is a composite control that can combine other ASP.Net controls and it is present in the form.
The DataList appearance is controlled by its template fields.
It displays data from the data source. The data source can be either a DataTable or a table from database.
DataList control has some Template Fields.
Itemtemplate specifies the Items present in the Datasource, it renders itself in the browser as many rows present in the data source collection.
EditItemTemplate is used to provide edit permissions to the user.
HeaderTemplate is used to display header text to the data source collection.
FooterTemplate is used to display footer text to the data source collection.
ItemStyle is used to apply styles to an ItemTemplate.
Let's examine a DataList example that retrieves data from a database.
This example gets data from the database table.
Add a web form to drag the DataList over it as we did in the figure.
Select DataList from the data category.
Drag the DataList to the form. After dragging, it looks like this figure.
Now, we need to configure database connection. Click on it and set new data source.
Connection parameters are defined in the connectionstrings block in the web.config file.
Data Source is the name of the connection that is required to connect SQL Server. It can be different for other computer systems.
It will pop up a new window with various Data Sources. Select SQL database and click ok.
After selecting Data Source, now, we need to select data connection.
But before proceeding further add connection string to the web.config file.
After finishing configuration, our DataList looks like this figure.
video txt