Explore the Premium Content

Using the DataGrid ItemDataBound Event

The DataGrid is of course probably the most popular and most implemented GUI control in ASP.NET 1.x. One of the fun parts of working with this control is the level of flexibility it brings developers allowing for unlimited combinations of creative implementations.

By applying different design patterns to the built-in functionality you can develop truly unique, robust, user friendly interfaces that allow your users to quickly and easily locate and manipulate the information in the application.

As you work with such a large scale component such as the DataGrid you will learn more and more about the capabilities over time. As your knowledge increases so does the complexity of your WebForms. Before long the amount of code in your code-behind files starts to exceed even your business tier or database tier logic.

Learning development pattern tricks to help manage the amount of code you develop is important in application maintenance. How many times have you come back to a WebForm a few months after you developed it and had to read the code for 30 minutes before you remembered what you did? This is a common occurrence in a lot of applications that don’t employ development standard patterns. Or worse yet, if you did not author the code yourself it can take you hours of research to unearth the processes behind other developers` code.

The purpose of this tutorial is 2-fold. First, we will look at a simple yet extremely helpful development pattern to help manage the columns in a DataGrid control. And second, we will look at how to implement correctly the ItemDataBound event of the DataGrid control to implement some advanced user interface display elements.

Note: Visual Studio .NET 2002/2003 running ASP.NET 1.x is required for this tutorial. Both VB.NET and C# code samples will be provided

Read More

DataGrid Columns in ASP.NET 1.x

Working with the DataGrid component in ASP.NET 1.x can be an overwhelming task at times. With so many configurable options available and a myriad of different attributes and parameters to work with your head can be spinning in no time.

How to present your data and how you want that data to interact with the user is usually the most important aspect to consider when designing your DataGrid component. You want your users to be able to find what they need and work with that data in an easy fashion.

The key component of the DataGrid when it comes to presentation is the DataGrid column objects. This in combination with some descent CSS styling attributes can create an aesthetic presentation that your users should find easy to work with.

With a lot of functionality pre-built into the DataGrid it’s important to take advantage of that functionality so that you are not constantly re-building features that are already available. The purpose of this article is to provide an overview of the different column types available on the DataGrid component and how they interact with some of the built in features.

By properly understanding the column types available and some of the key built in features you will be able to easily and rapidly create DataGrid components that are user friendly and easy to develop.

Note: Visual Studio .NET 02/03 running ASP.NET version 1.x is required for this tutorial. Both VB.NET and C# code samples will be provided

Read More

Summarizing database content using record count and displaying a recordset

Richard shows you how to use the total "records count" from the bindings panel to summarize table contents in a paragraph.

Next to that he teaches you how to apply the  "Show Region" server behavior to display a recordset to a page. He also enables you to show an appropriate message if the recordset does not contain data.

This movie continues with the sample site that was used in last weeks tutorial.


Read More

Creating a Pageable Sortable DataGrid in ASP.NET

When working with the DataGrid component it’s often important to stay on top of performance and to provide an easy to use interface. Sometimes a lot of work and effort goes into making a great DataGrid display and layout but some of the details get lost along the way.

There are 2 features that are built into the DataGrid which can help make your end users lives a little easier when working with larger amounts of data. These 2 features are paging and sorting. Paging refers to taking a large set of data and paging it across multiple pages instead of presenting all of the rows at once, and sorting of course refers to allowing the user to sort the data by certain columns. Both provide a way for your end user to find the data they are searching for a little easier.

There does come certain overhead with using these features, but this is usually the price you pay for providing a richer user interface. There are a couple different ways to provide these features as well. We will look at the fastest and easiest way to implement both.

In this tutorial we will implement a simple ASP.NET sample application which displays a listing of products from the sample Northwind SQL database. We will implement the sample application in 3 stages. The first stage we will build the connection and get our DataGrid to simply display a listing of products.

In the second stage we will add sorting to the DataGrid so that you can click on certain column headings, and in the third stage we will add paging to the DataGrid using the default paging features without customization.

Note: Visual Studio .NET running ASP.NET ver 1.x is required for this tutorial. Access to a version of SQL Server is also required as we will use the sample Northwind SQL database to connect to. Both VB.NET and C# code samples will be provided

Read More

Building Your First ADO.NET Application – Part 2

Welcome to the second and final part of this tutorial regarding how to build an ASP.NET application that utilizes ADO.NET as the data provider. During part 1 we explored the scenario where a single developer builds everything from the database up in a 2-tier design by utilizing the data wizards of the data controls designed for ASP.NET WebForms.

The purpose of this second part of the tutorial is to build the same features that were built during part 1, but instead to use an N-tier design to create a more reusable data tier. Although this process is much more manual it gives the developer greater flexibility and control over the data source coding and allows them to implement object oriented patterns which can be reused across the application.

Note: Visual Studio .NET running ASP.NET version 1.x is required for this tutorial. Access to SQL Server is not required but preferred, you must have access to a database however in order to properly implement the sample code. Both VB.NET and C# code samples will be provided

Read More

Applying the User Authentication Server Behaviors

Richard Mariner will show you how to add security to your site by creating a login box. This movie continues with the sample site that was used in last weeks tutorial.

 


Read More

Building Your First ADO.NET Application Part 1

If you’re new to the world of ASP.NET development or even just .NET development in general you’ve probably heard of ADO.NET at some point. The ironic part about ADO.NET is that it is utilized in probably 99% of applications yet it is rarely discussed as its own entity. ADO.NET simply sits and hides in the background and does its job.

ADO.NET is not a part of ASP.NET; it is a part of the .NET framework as a whole and represents the data source connectivity layer of the .NET framework. It can be used from either ASP.NET or WinForms applications in the same manner. In fact you could theoretically take the data tier from an N-tier application built for ASP.NET and apply it to a WinForms application without changing a single line of code. This is the fundamental principle behind a reusable framework. ADO.NET provides the building blocks for data source access and manipulation in an abstract fashion and can be applied to any application type in the .NET framework.

Now you might be wondering about the title of this tutorial, if ADO.NET is merely a data source connectivity framework, how can it be used to build an application? The truth is it can’t, but ADO.NET does make up the data source interaction layer of any .NET application, and in our case we’ll use it to build the data tier in an ASP.NET sample application.

The purpose of this tutorial is not to focus on the ASP.NET portion of the .NET framework. This means we will not focus on user interface, forms, authentication and so forth, but instead we will try to take common requirements in a web application and use ADO.NET to provide those requirements.

Sometimes when working in a development team there would be dedicated developers who build strictly the data tiers and the interface developers use the functionality provided to build the user interface. Other times one single developer works from the database up, providing all functionality.

For this tutorial we will examine 2 approaches. During part 1 we will explore the scenario where a single developer builds everything from the database up in a 2-tier design by utilizing the data wizards of the data controls designed for ASP.NET WebForms. During part 2 we will explore how to provide the same features in an N-tier application with a more robust dedicated data tier, linking to the user interface of ASP.NET WebForms.

The approach we will take will not be focused on a real world application with properly laid out interfaces, but rather real world ‘scenarios’ that you will likely encounter everyday as a developer. Since ADO.NET isn’t an integral part of the user experience or interface we need to explore common development situations and how to solve them.

Note: Visual Studio .NET running ASP.NET ver 1.x is required for this tutorial. Access to SQL Server is not required but preferred, you must have access to a database however in order to properly implement the sample code. Both VB.NET and C# code samples will be provided

Read More

ADO.NET Concepts for Beginners

With nearly any application, a data source is likely to be the root foundation of all functionality. Without being able to store data your application obviously won’t be able to do a whole lot. The database, or data source, and your application’s code base cohesively comprise what we call an application; neither the code nor the data source would be of much use without the other.

Being such a fundamental component of an application, methodologies for working with data sources has evolved greatly over the years. If you recall classic ASP there was very little structure or design behind the database connections and data manipulation patterns

With classic ASP you needed to use ADO, which were COM classes you could instantiate nearly anywhere on any ASP page and could read/write data in any arbitrary location on the script. Although the classes were well defined and quite handy to work with, they left developers to their own devices when trying to design database patterns.

Unless you had your database logic in an ActiveX DLL you also didn’t have access to the helpful code-insight shortcuts which would make development much easier since you could clearly see the methods and properties available to you. If you scripted your database logic in ASP pages it was usually a matter of trial and error, changing code and refreshing the page to test over and over.

The next generation of ADO has been labelled ADO.NET since its creation coincided with the release of the .NET framework. ADO.NET is now a managed set of clearly organized classes which can connect to nearly any data source you can think of.

No longer is your database code embedded into your front end pages; now you can define entire dedicated components to house your database logic and access them in an Object Oriented fashion. Additionally, the data wizards for the Data category of ASPX controls are capable of writing the data connectivity code for you, so developers that are not familiar with ADO.NET can still write database connected applications.

One of the troubles with these wizards however is that you really don’t have a grasp of what’s happening in the code-behind files to make your database connectivity happen. If you encounter a bug it’s difficult to track down because you didn’t write the code yourself.

The purpose of this tutorial is to look at some of the basic principles behind ADO.NET and its classes, as well as look at some common methods and properties used to access data.

Note: ADO.NET can be utilized in any type of Visual Studio .NET project. For this tutorial we will assume ASP.NET is the project type. Visual Studio .NET is not required but recommended if you want to test out some sample code, and installation of the MSDN library is required to follow the links provided in the tutorial

Read More

How to identify an email as open, mark it as closed and have it automatically archived

Last week Richard showed you how to create a form that validates data and is connected to a database. This week Richard is back with another great video tutorial that teaches you how to create an e-mail management system that shows which of the sent e-mails (that where generated by last weeks form) are open and how to close and archive them in a database.


Read More

Creating a form that validates and writes to a dabase

Ever wanted to create a form that validates data and is connected to a database? Richard Mariner shows you how to create a Contact Form that validates and writes it's content to a database table in less then 5 minutes!

Read More

Building Your First ASP.NET 1.x Application – Part 2

Welcome to the second and final part of this 2 part series regarding how to construct your first ASP.NET application using Visual Studio .NET and SQL Server.

During Building Your First ASP.NET 1.x Application – Part 1 we explored how to use IIS step by step to configure a new virtual directory which can then be used as a project source name for new ASP.NET applications. We also learned how to add CSS visual styling to ASP.NET WebForms, and finally we learned how to use the ADO.NET Data controls for WebForms to connect to an SQL server database.

In this second part of the tutorial we will build upon our sample ASP.NET application and implement the functionality required to allow user login and forms authentication, as well as how to bind data to a DataGrid and DropDownList.

To achieve these requirements we will learn how to work with another ADO.NET data control available in Visual Studio .NET called the SqlCommand object. In addition to this we will learn how to create stored procedures in SQL Server and execute them from our WebForms in order to retrieve the data we need for the required features.

Note: Visual Studio .NET 02/03 running ASP.NET version 1.x is required to implement this tutorial. Additionally, access to an SQL Server with the built in Northwind database is highly recommended as it is the database used as the data source for this tutorial. If you are comfortable with database connectivity you may apply the techniques in this tutorial to another database of your choice.

Both C# and VB.NET code samples will be provided

Read More

Building Your First ASP.NET 1.x Application – Part 1

When working with a complex application framework such as ASP.NET 1.x it’s tough to know where to begin sometimes. Which areas to design first, what pages to add, how to wire up your database, how to create a secure area and a login form, are some common obstacles you’ll come across when you dive into Visual Studio .NET and actually start development.

There really is no one-size-fits-all approach to starting a web application since there are simply too many factors to consider, and each application will have its own unique set of requirements. Typically you will take a simple 2-tier approach to your application unless you’re working with a large client with a very large amount of concurrent users.

In order to be cost effective in your development timeline a 2-tier approach will cut some of the advanced design principles in favour of delivering a product quickly to the customer. The definition of 2-tier means there are no middle tier or database tier components, your web forms will communicate directly with the database.

The reality is that 2-tier designs are very unscalable and difficult to maintain. However not every client can afford the extra effort required to make everything nice and object oriented and scalable to large amounts of users, servers and dedicated components.

So for the most part you’ll likely find yourself developing small applications which require a quick rollout to production and delivery to the customer. Using the 2-tier approach with the built in data wizards in .NET will help facilitate this process.

When you’re first starting out with ASP.NET you’ll likely not know where to start, even when using a simple 2-tier design framework. The purpose of this article is to take some very basic features which you’d find in almost any application and show you how to develop them step by step.

Note: Visual Studio .NET 02/03 running ASP.NET version 1.x is required to implement this tutorial. Additionally, access to an SQL Server with the built in Northwind database is highly recommended as it is the database used as the data source for this tutorial. If you are comfortable with database connectivity you may apply the techniques in this tutorial to another database of your choice.

Both C# and VB.NET code samples will be provided

Read More
Newer articles Older articles