Library tutorials & articles
In Depth ASP.NET using ADO.NET
- Introduction
- Developing a Templated DataBound Control
- Table, TableRow, and TableCell Web Server Controls
- Adding Rows and Cells to a Table Web Server Contro
- Data Binding Button, TextBox and DropDownList cont
- Data Binding Expressions
- Exploring with Web Based Address Database
- Adding CheckBox Control to DataGrid Control
- Data Navigation Form with Unbound Controls
Introduction
In this article we will discuss a number of ways to retrieve, show, and update data with ASP.NET forms using ADO.NET. Also, we will have a clear idea about the most common server controls in ASP.NET. In particular, with this article we will cover ASP.NET server controls, ADO.NET DataSource, and creating Templated DataBound Controls, ASP.NET forms, using data with controls. We will review each of the proceeding server controls in detail. We will learn how to raise and handle some of the controls events, how to retrieve attributes from the control programmatically on the server, and finally we will demonstrate how to bind to control to a data source. Finally, we will have a complete example of retrieving, showing and updating by using server controls of ASP.NET.
Characteristically, when working with information or data from users we need to validate the data they provide us. For instance, if we have a field in our form where the user must enter his date of birth, we probably will want to control that user so that he enters a valid date. In this article we will not be validating the data collected, but we will use several server controls to handle data.
Construction Data with ASP.NET and ADO.NET
An ASP.NET server control derives directly or indirectly from System.Web.UI.Control. This base class belongs to the System.Web.UI namespace, which contains the elements common to all ASP.NET server controls. Three commonly used controls Page, UserControl, and LiteralControl are belong to System.Web.UI.Control developers generally do not instantiate Page or derive from Page. Page is important because every ASP.NET page is compiled to a Page control by the ASP.NET page framework,. Control developers also usually do not work with UserControl. User controls are developed using the same programming model as ASP.NET pages and are saved as .ascx text files. As it allows text to be encapsulated as a control, Control developers use LiteralControl widely.
IIS needs to be properly configured with FrontPage extensions for ASP.NET pages to execute. The required version of FrontPage extensions needs to be installed during the .NET SDK install or the Visual Studio .NET install. To verify this, open the Internet Information Services Manager and right-click the default Web site, and select Check Server Extensions from the All Task menu.
By extending an existing Web server control, by combining existing Web server controls, or by creating a control that derives from the base class System.Web.UI.WebControls.WebControl, we can develop a custom Web server control.
We will find typical scenarios in which we are likely to develop our own controls and provide links to other topics for further information in the following list.
- We have created an ASP.NET page that provides a user interface that we want to reuse in another application. We would like to create a server control that encapsulates the user interface (UI) but we do not want to write additional code. ASP.NET allows us to save our page as a user control without writing a single additional line of code. For details, see Web Forms User Controls.
- We would like to develop a compiled control that combines the functionality of two or more existing controls. For example, we need a control that encapsulates a button and a text box. We can do this using control composition, as described in Developing a Composite Control.
- An existing ASP.NET server control almost meets our requirements but lacks some required features. We can customize an existing control by deriving from it and overriding its properties, methods, or events.
- None of the existing ASP.NET server controls (or their combinations) meets our requirements. In that case, we can create a custom control by deriving from one of the base control classes. These classes provide all the plumbing needed by an ASP.NET server control, thus allowing us to focus on programming the features we need. To get started, see Developing Custom Controls: Key Concepts and Developing a Simple ASP.NET Server Control
Many custom controls include a combination of scenarios, where we combine custom controls that we have designed with existing ASP.NET server controls.
The ASP.NET server controls that provide a user interface are organized into two namespaces; System.Web.UI.HtmlControls and System.Web.UI.WebControls. While the Web server controls are richer and more abstract, the HTML server controls map directly to HTML elements.
Most Web server controls derive directly or indirectly from the base class System.Web.UI.WebControls.WebControl. On the other hand, the four controls in the upper-right corner (Literal, PlaceHolder, Repeater, and Xml) derive from System.Web.UI.Control. The controls on the left map to HTML elements. The controls in the center are for validating form input. Also the controls that are in the center provide rich functionality, such as the Calendar and the AdRotator controls. The controls which provide data binding support are on the right.
Before we start to talk about the server control, we will have some additional information about DataBound controls. Let's take a look at how we can develop a Templated DataBound control.
Related articles
Related discussion
-
PrintDocument printing using DOS print
by squrrel (1 replies)
-
hey developers out there
by pitsophera (0 replies)
-
building query at run time in ADO.NET using c#
by sudam.chavan@gmail.com (1 replies)
-
Using ADO.NET with SQL Server
by Manjot Bawa (23 replies)
-
High-Performance .NET Application Development & Architecture
by Manjot Bawa (0 replies)
Related podcasts
-
ADO.NET Data Services in .NET 3.5 Service Pack 1 Beta1 with ASP.NET AJAX
Wally walks through using ASP.NET Podcast Show #114 - ADO.NET Data Services in .NET 3.5 Service Pack 1 Beta1 with ASP.NET AJAX.
Events coming up
-
Mar
15
DevWeek 2010
London, United Kingdom
DevWeek is Europe’s leading independent conference for software developers, database professionals and IT architects, and features expert speakers on a wide range of topics, including .NET 4.0, Silverlight 3, WCF 4, Visual Studio 2010, REST, Windows Workflow 4, Thread Synchronization, ASP.NET 4.0, SQL Server 2008 R2, LINQ, Unit Testing, CLR & C# 4.0, .NET Patterns, WPF 4, F#, Windows Azure, ADO.NET, Entity Framework, Debugging, T-SQL Tips & Tricks, and more.
singhswat@yahoo.co.in
Actually ado.net and asp.net connectivity has lot more than it this indepth article has of no use because it doesnt hv any example/s associted with it
This is not ASP.NET It's VC++.NET ASP.NET is a web based language, not a windows forms language.
This thread is for discussions of In Depth ASP.NET using ADO.NET.