New Server Controls Provided by the ASP.NET Web Matrix

Recently, the second version of the ASP.NET Web Matrix was released to the public. The Web Matrix is a free .NET development tool provided by Microsoft® that allows you to build ASP.NET pages as well as XML Web services in either Microsoft Visual Basic® .NET, C# or J#. You can download the Web Matrix from the ASP.NET Web site.

Many Web developers who have been primarily working with Microsoft's other IDE, Microsoft Visual Studio® .NET, might not yet have taken a look at the Web Matrix, thinking that there isn't anything there for them. But the Web Matrix is worth a look, even if you are primarily using Visual Studio .NET for your ASP.NET development.

The Web Matrix is an outstanding IDE. It is lightweight, fast, and allows you to quickly and easily build your ASP.NET pages. This article will take a look at some of the new server controls that the Web Matrix has that you cannot find in Visual Studio .NET. Finally, we'll take a look at how to import these new server controls from the Web Matrix into Visual Studio .NET for those developers who prefer working with Visual Studio .NET.

New Web server controls

  • SqlDataSourceControl
  • AccessDataSourceControl
  • MxDataGrid

This article will primarily look at the new Web server controls, as they are the most exciting new additions.

SqlDataSourceControl

If you have been working with ASP.NET a while using Visual Studio .NET, you will know that if you want to display data from a Microsoft SQL Server™ table within a DataGrid server control, that there are typically a lot of steps that you have to take before this is accomplished. For instance, to do this, you will have to create a number of new objects first. The first thing you need to do is create a SqlConnection object followed by a SqlCommand object. Once those objects are in place, you can then create a SqlDataReader to populate your DataGrid by binding the result to the DataGrid. In the end, this will give you a table containing the contents of the data you were retrieving (such as the Customers table from the Northwind database).

Microsoft has made this process considerably easier for us now with the addition of this new server control provided by the Web Matrix—the SqlDataSourceControl server control. The SqlDataSourceControl takes care of all of these extra steps for you. By using this server control, there is therefore no need to create all these additional objects just to work with SQL data.

AccessDataSourceControl

In addition to being able to easily connect to SQL Server using the SqlDataSourceControl, you can also connect to any Microsoft Access database (an .mdb file) just as easily by using the AccessDataSourceControl that is provided with the Web Matrix.

There isn't that much difference between these two new ASP.NET Web Matrix data controls. You work with the AccessDataSourceControl in same manner as the SqlDataSourceControl.

MxDataGrid Server Control

The MxDataGrid server control is also a brand new server control that is included in the Web Matrix, but is not available in Visual Studio .NET. This control is quite similar to the DataGrid control, but makes turning on paging and sorting of a DataGrid far easier than using the traditional DataGrid Web control.

Read more here

 

No Comments