Declarative Programming in ASP.NET 2.0
So, how easy is 2 tier development in ASP.NET. Pretty Simple:
<HTML>
<BODY>
<B>ASP.NET 2.0</B><br>
A Test page for some of the ASP.NET 2.0 Features<br>
<form runat="server">
<asp:SqlDataSource id="ds1" runat="server"
ConnectionString="server=localhost;database=Northwind;uid=sa;pwd="
SelectCommand="Select ProductId, ProductName, QuantityPerUnit, UnitPrice, UnitsInStock, Discontinued From Products"
/>
<asp:GridView id="grid1" DataSourceId="ds1" runat="server" />
</form>
</BODY>
</HTML>
So, what do we have here? One of the goals of ASP.NET 2.0 is to continue to decrease the amount of code the developer has to write. To that end, more programming can be done declaratively. I honestly do not know what that means, but, from the context of the word, it appears that there are more controls that you can put on a page and set a series of properties.
Take for instance the new Data Source Controls. This example uses the SqlDataSource, which can be used to connect to a SQL server. All you have to do is provide a connection string and a select statement and the control will create your command, connection, data adapter and even fill a dataset for you. There are many more attributes that you can specify, including Insert, Update and Delete statements.
BTW, went back to B&N and bought ASP.NET v2.0 The Beta Version by Homer, Sussman and Howard. If you are playing with the betas, this is an invaluable “field guide!”
C