Monday, February 8, 2010

How can I use Source Control in ASP.NET?

please help me I am in bad situation. I need to know the way of using Source control in VS.net 2008 for a web Project.


thanksHow can I use Source Control in ASP.NET?
ASP.NET 2.0 introduces a series of new tools that improve data access including several data source and data bound controls. The new assortment of data source controls can eliminate a ton of repetitive code that was required in ASP.NET 1.x. For example, you can easily associate SQL statements or stored procedures with data source controls and bind them to data bound controls. Even more impressive, the ObjectDataSource control allows you to take advantage of the simplified development and reduction of code but still allows you to abstract your business and data access logic in separate tiers of your n-tiered architecture.


Before .NET, building data grids with traditional ASP often required you to write a lot of code to build an HTML table on the fly while looping through an ADO Recordset. ASP.NET 1.x made this type of development easier by allowing you to bind an XML-based DataSet to the ASP.NET DataGrid control. This reduced the code required to generate the grid. However, both traditional ASP and ASP.NET 1.x require code to implement paging, sorting, editing and row-selection features. With the improvements in ASP.NET 2.0, this code can be significantly reduced to produce a data-filled grid with full paging, sorting, and editing features.


In this installment of Data Points, I will begin by demonstrating how easy it is to develop a Web application with ASP.NET 2.0 using the SqlDataSource and some of the new data-bound controls. Note that I have used the Beta 1 release here.


Most enterprise applications are built on multitiered architectures with a middle tier that holds the business logic and a data access layer that works with the backend database (or databases). I will discuss how the ObjectDataSource is ideal for integrating with existing multitier components. By linking the ObjectDataSource control to business objects, you are able to leverage an existing multitiered architecture and take advantage of the significant reduction in code to generate a sophisticated Web UI. The ObjectDataSource control also contains some special properties that allow binding to the newly enhanced strongly typed DataSet and data components in ASP.NET 2.0 and ADO.NET 2.0. Other new features and improvements in ASP.NET 2.0 include the new two-way binding expressions, enhanced caching, and several new ASP.NET 2.0 controls that can be data bound to the new data source controls.








Data-Bound Controls


To use the data source controls you must have a data-bound control to bind them to. There are several new data-bound controls in ASP.NET 2.0, including the GridView, DetailsView and FormView controls. If you are fond of the ASP.NET 1.x DataGrid control, you will love the ASP.NET 2.0 GridView control. The GridView is like a DataGrid on steroids as it can be bound to the new data source controls, and can be used to implement sorting, editing, and paging, all with much less code than the DataGrid required (for more information on the GridView, refer to Dino Esposito's article from the August 2004 issue of MSDN庐Magazine,).


To bind a GridView to a data source control, you set the GridView's DataSourceID property to the ID of the data source control. There are several other properties of the GridView that can be set to enhance appearance and user interaction that I will demonstrate in the later examples:


Copy Code


%26lt;asp:GridView ID=';gvwOrders'; Runat=';server';


DataSourceID=';sdsOrdersDataSource';


AutoGenerateColumns=';True';%26gt;


Other controls, such as the DropDownList, can also be bound to the data source controls. For example, a DropDownList control can be bound to a SqlDataSource control that retrieves a list of employees. The employee's full name could be displayed in the DropDownList while the EmployeeID could be bound to the control as its underlying data value field. The following example defines a DropDownList that will display a list of customer names that can be selected. The customer data is bound to the SqlDataSource control named sdsCustomerDataSource which gets a list of customer CompanyName and CustomerID fields:


Copy Code


%26lt;asp:DropDownList ID=';ddlCustomers'; Runat=';server'; AutoPostBack=';True';


DataSourceID=';sdsCustomersDataSource';


DataTextField=';CompanyName';


DataValueField=';CustomerID';%26gt;


%26lt;/asp:DropDownList%26gt;


Binding a control to a data source control is quite simple in ASP.NET 2.0 and does not require any code in a codebehind. However, you can still write code to explicitly bind to the controls if you want to. In fact, the data source and DataMember proper-ties of data-bound controls have been brought forward from ASP.NET 1.x, as well.








Data Source Controls


There are several new data source controls in ASP.NET 2.0, such as the SqlDataSource, ObjectDataSource, XmlDataSource, AccessDataSource, and SiteMapDataSource (shown in Figure 1). They all can be used to retrieve data from their respective types of data sources and can be bound to various data-bound controls. Data source controls simp
  • Scooter
  • No comments:

    Post a Comment