The display of information from a database is a fairly standard requirement on most websites and, in some development environments, it can take a fa...
The display of information from a database is a fairly standard requirement on most websites and, in some development environments, it can take a fair amount of programming to achieve. In ASP.NET, however, it is remarkably easy, thanks to the use of built-in data-bound controls. There are two types of data-bound controls: those which are designed to display multiple records and those which will display one record only. The GridView control, the workhorse of databinding in ASP.NET, falls into the first category. It automatically generates an HTML table and fills it with information from a given data source with each record in the database rendered as a row in the table.
When using Visual Web Developer the easiest way to create a GridView control is simply to explore the appropriate data source using the database explorer, then drag the appropriate table or view onto the page. This action creates both a DataSource object and a GridView object, both of which can be customised either in Design or Source view. If the listing you wish to display on the page is to be tabular, you may not need to change the default GridView. However, it is more usual that you will want to customize the way in which data is displayed.
Naturally, you do not have to display all of the fields in the database in the HTML table generated by the Gridview. The GridView’s AutoGenerateColumns attribute should be set to False (which it is by default). Additionally, we can display data in a number of different ways. By default information is displayed in a BoundField, meaning that the data is displayed as text. By default, the heading displayed at the top of each column is simply the name of each field in the database. However, you can modify this by changing the HeaderText property of each BoundField element. Another useful property is DataFormatString which allow you to use a format string to control the display of data.
Another useful form of customization is the display of data in a choice of other HTML formats: CheckboxField, RadioButtonField, HyperlinkField, ButtonField and ImageField. The final type of field is CommandField which enables you to display links enabling the user to edit, delete or select rows of data.
For even greater flexibility, the GridView control also provides the TemplateField which allows you to place any HTML content you like in a given column and use databinding statements to embed information from the database as required. Template fields can even contain ASP.NET server controls.
You can find out more about ASP.NET training courses, visit , a UK IT training company offering in London and throughout the UK.
Extensible Mark-up Language (XML) has quickly established itself as a viable technology with a huge range of real-world applications. One of the key reasons for its importance and wide acceptance is that it offers a working solution to one of the key problems faced by software developers and computer users alike: the exchange of incompatible data. Each software environment produces its own unique type of binary file which only it can understand. Once data is exported in XML format, it becomes a known quantity, independent of the environment in which it was originated.
The PDF format is another example of a platform-independent format which has gained worldwide acceptance. Once a document is saved in PDF format, its format is set in stone, it can viewed and printed with its layout and formatting intact, without the need for the software which created the original document. However, where the PDF format concerns itself mainly with the presentation of information, XML is used to describe and encapsulate the information itself.
Though XML itself is still fairly new, the idea behind is over thirty years old. In the 1970s, Standard Generalized Markup Language (SGML) was developed in an attempt to create an application-independent method of describing and storing data. SGML is a text-based language which relies on the concept of adding mark-up to data which describes the data itself. An SGML document contains both the original data and a lexicon of rules defining the structure of that data. SGML is a fairly complex language and, unlike XML, has never gained wide popularity. In the early 1990s, SGML was used to develop and specify the rules of HyperText Markup Language (HTML) and in the late 1990s, SGML was again called upon, this time as the basis for the creation of XML. In a lot of ways XML is basically a restricted form of SGML.
XML has already proved itself an excellent medium for storing, describing and transporting data, particularly over the web. It offers flexibility, clarity and simplicity. An XML document looks similar to an HTML document and consists of the same human-readable tags. However, the tags used to markup an HTML document are pre-defined: only a limited set of tags can legitimately be used. XML allows you to create a markup language and define the tags which are legitimate for your data. It does this using a schema document, which can itself be an XML document. The schema document specifies the vocabulary and grammar which may be used within the XML document which contains your data.
The fact that, when creating and generating XML documents, you can invent all the rules, means that you never have to force your data into a container which was not designed to hold it. You design tags which reflect the nature of your data; you create a schema document which defines the hierarchical structure of your information; and you specify the type of information each element within your document is permitted to contain. In short, if you end up with an XML documents which is unsuitable for holding your information, you have only yourself to blame!
Author’s company runs in London and throughout the UK.
Displaying information on a web page which comes from a database is a fairly standard requirement on most websites and, in some development environments, it can take a fair amount of programming to achieve. In ASP.NET, however, it is remarkably easy, thanks to the use of built-in data-bound controls. There are two types of data-bound controls: those which are designed to display multiple records and those which will display one record only. The GridView control, the workhorse of databinding in ASP.NET, falls into the first category. It automatically generates an HTML table and fills it with information from a given data source with each record in the database rendered as a row in the table.
In Microsoft Visual Web Developer, you can create a Gridview by simply exploring the appropriate data source using the database explorer then dragging the appropriate table or view onto the page. This action creates both a DataSource object and a GridView object, both of which can be customised either in Design or Source view. If the listing you wish to display on the page is to be tabular, you may not need to change the default GridView. However, it is more usual that you will want to customize the way in which data is displayed.
Naturally, you do not have to display all of the fields in the database in the HTML table generated by the Gridview. The GridView’s AutoGenerateColumns attribute should be set to False (which it is by default). Additionally, we can display data in a number of different ways. By default information is displayed in a BoundField, meaning that the data is displayed as text. By default, the heading displayed at the top of each column is simply the name of each field in the database. However, you can modify this by changing the HeaderText property of each BoundField element. Another useful property is DataFormatString which allow you to use a format string to control the display of data.
Where appropriate, you can also display data in a choice of other HTML formats: CheckboxField, RadioButtonField, HyperlinkField, ButtonField and ImageField. The final type of field is CommandField which enables you to display links enabling the user to edit, delete or select rows of data.
For even greater flexibility, the GridView control also provides the TemplateField which allows you to place any HTML content you like in a given column and use databinding statements to embed information from the database as required. Template fields can even contain ASP.NET server controls.
If you would like to learn more about ASP.NET training courses, visit , an independent computer training company offering at their central London training centre.