ASP.NET Web Server Controls

This Post shows  How to Use Server Controls in Asp.Net Web Pages

ASP.NET Server controls
1) Html Server Controls (HtmlAnchor Control, HtmlButton Control, HtmlForm Control, HtmlImage Control…).
2) Web Sever Controls
• Basic Web Controls (Button, Checkbox, Hyperlink…).

• Validation Controls (RequiredFieldValidator Control, RangeValidator Control, CompareValidator Control..).

• List Controls (ListBox, CheckBox, RadioButtonList, Repeater, DataList, GridView, DropDownList, ListView).

• Rich Controls (AdRotator, Calender).
• User Controls.
• Custom Controls.

Table comparison is the easiest way to quickly decide which data list control is best for your specific project requirements.

Always go for the control that provides the built in feature for your needs. But In most real-life examples, you would need to write some amount of custom code to make sure that the resulting Web page shows information in the most desirable format. When choosing the control look for performance, ease of use and maintainability effects to determine the best practice.

Real time Scenarios.

Case 1: Displaying 100 records from the database using DataBind().

Comparing performance differences between the data grid, data list, and repeater controls.

Option 1 is the repeater solution, option 2 is the data list solution, and option 3 is the data grid solution.

Of the three solutions, recommended is that you consider the data list control as your first choice. Look at the data grid control only when you discover that data list doesn’t provide a desired built-in feature. Similarly, you should use the repeater only when the data list control is too slow for your needs.


  1. Datagrid is most restrictive as regards to customization followed by DataList and finally Repeater is the most customizable.
  2. Datagrid has built in paging, sorting and editing capabilities which are not there with the other two controls. So if you want users to sort / page / edit data, datagrid is the natural choice.
  3. DataList and repeater have better performance than datagrid. So if performance is a major concern, for example, a site with large number of concurrent visitors, then you could think of datalist or repeater.
  4. Repeater is the most customizable. It allows you to create structures like nested lists, for example.
    A datagrid row displays one record from the data source, while a datalist row can display more than one records (set by RepeatColumns property).
  5. Datagrid and Datalist are derived from WebControl while Repeater is not, and so does not have the stylistic properties of web controls.
  6. Datalist can display more then one record in a single row. While Repeater can’t.
  7. Datalist has a property called repeat. Direction = vertical/horizontal. (This is of great help in designing layouts). This is not there in Datagrid.
    1. With same template and same data set, Repeater usually works faster of DataList or GridView controls. This is mostly because of DataReader class, which is used for read only access. DataReader is faster than DataSet or DataTable classes commonly used with GridView.
    2. DataList has RepeatDirection, RepeatColumns and RepeatLayout properties, which are unique for DataList control. These properties are useful when you need to create presentation with more than one record per row, like image gallery, product catalog etc.

10. Common problem when using GridView control could be large ViewState which makes page loads slower and requires more bandwidth. This could be insignificantly on low traffic website, but keep in mind that for each second while the page loads, the percentage of visitors will become impatient and leave website. Also, massive view state is not good for SEO (search engine optimization).

11. One more problem is using of default pager on large tables or high traffic websites. If default paging is used, GridView will load complete dataset in memory, which descreases website’s performances.

12. Since Repeater control does not generate additional HTML, it also can be used to generate RSS feeds.


Thus, we have understood the various databound controls and its advantages and disadvantages which will help us to choose the right control for our need.

To sum up,

  • Choose Gridview if your requirement is displaying tabular data. For example, a search result page where the customer expects a sorting clicking on the header. Also, it is very easy to provide custom paging with GridView when we use ObjectDataSource control.
  • Choose between DataList and Repeater control for flow/tiled layout. DataList control will help you in providing editing the data where Repeater will not.
  • If you use ASP.Net 3.5, then ListView control will satisfy almost all of your need in terms of the layout of the data display. This control is most flexible and versatile that can fit all your need.

Don’t forget to switch off the viewstate if your need is only display to get better performance.

1. If your Data access operations is mainly fetching and displaying the records and doesnt involve insert/update/delete statements and other manipulations (forward only, read only) actions, go for the DataReader.
DataReader offers a forward only read stream of access to the records. It is very useful in cases where we just grab the data from the database to display in DataGrid, Label and other Webcontrols.
However, DataReader requires the connection with the database open until its operation is completed.

2. If your Data access operations extend to as simple as an Insert/Update/Delete statement to as complex as using it as a return type from a web service, go for the DataSet. The DataSet has the following advantages.

i. Complex Data type supporting numerous methods such as ReadXML which reads new XML data to form a dataset, WriteXML which provides an XML format of the existing data, etc.,
ii. Works on the disconnected architecutre i.e. The connection doesnt need to be on for the DataSet to perform the manipulations and other actions and is required only at the time of Updating the records to the Database Table.

Reference : Dilip Kumar Jena ( )