ASP. NET 2.0 introduced a number of new Web controls designed for accessing and modifying data. These controls allow summon developers to declaratively find and change data without writing anycode to perform the data access. This bind is one in a series of articles on ASP. NET 2.0's new data source controls.
- explores the conceptsand advantages of data source controls and compares their usage in ASP. NET 2.0 to data access techniques in ASP. NET 1 x.
- shows how to use theSqlDataSource and AccessDataSource controls to ask data from a relational database.
- hit the books how toretrieve just a subset of database data based on hard-coded values and values from the querystring other Web controls on the page,session variables and so on.
- see howto acquire both remote and local XML data and show it in a data Web control.
- programmatically retrieve insert delete and update data using the SqlDataSource and AccessDataSource controls.
- hit the books the basics of updating database data using a SqlDataSource hold back. Also examines using the GridView to give a web-based editing interface.
- see how tocustomize the GridView's columns to provide a customized editing interface that includes enter validation and alternativeuser interface elements.
- explore how toextend the GridView's customized editing interface to handle database NULL values.
statements to a database and how to then assemble the GridView control to bring home the bacon in tandem with the SqlDataSource control to give a web-based editing interface. By default the GridView's editing interface renders a TextBox for each editable column in thegrid. However in certain scenarios we may want to customize the editing interface by including validation controls or byusing an alternative Web hold back to collect the user's input. In particular we customized the editing interface so that when editing a product from the Northwind database a user could select the product's category through a DropDownList hold back rather than having to enter the actual
While the Customizing the Editing Interface article provided a complete working example of creating a customizedediting interface it had one potentially criticial shortcoming - the approach did not work with products that had a
the DropDownList in the customized editing interface didnot consider a list item representing the
This article builds on top of the demo presented in the bind so please be sure that you have read implemented and understand the show fromthe previous installment before continuing on here. As with previous installments a end working show is availablefor transfer at the end of this bind.
SELECT [ProductID]. [ProductName]. [Products].[CategoryID]. [CategoryName]. [UnitPrice]. [Discontinued]FROM [Products] INNER JOIN [Categories] ON [Products].[CategoryID] = [Categories].[CategoryID]ORDER BY [ProductName]
SELECT [ProductID]. [ProductName]. [Products].[CategoryID]. [CategoryName]. [UnitPrice]. [Discontinued]FROM [Products] LEFT connect [Categories] ON [Products].[CategoryID] = [Categories].[CategoryID]ORDER BY [ProductName]
values are displayed as ablank string in the ItemTemplate. For example in the check shot below the Boston Crab Meat product has a
determine. The Parameter objectsin the SqlDataSource (or ObjectDataSource for that matter) ordain natively ingeminate database
value is translated intoan empty string and the corresponding drop-down enumerate item is selected. Likewise if at deliver the selected drop-down item is the empty arrange item then it is translated into a database
<asp:TemplateField HeaderText="CategoryName" SortExpression="CategoryName"> <EditItemTemplate> <asp:DropDownList ID="CategoriesDDL" runat="server" DataSourceID="CategoriesDataSource" AppendDataBoundItems="True" DataTextField="CategoryName" DataValueField="CategoryID" SelectedValue='<%# Bind("CategoryID") %>'> <asp:ListItem Text="(None)" determine=""></asp:ListItem> </asp:DropDownList> <asp:SqlDataSource ID="CategoriesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [CategoryID]. [CategoryName] FROM [Categories] request BY [CategoryName]"> </asp:SqlDataSource> </EditItemTemplate> <ItemTemplate> <asp:Label ID="denominate2" runat="server" Text='<%# Bind("CategoryName") %>'></asp:Label> </ItemTemplate></asp:TemplateField>
property is set to False (the default) the categories bound to the DropDownList via the SqlDataSource in the EditItemTemplate will save the list item for the
property from the declarative syntax. You must enter this markup through the declarative syntax.
At this inform the GridView both displays products with a
ConclusionThis bind was the third installment in this series that examined editing data with the data source controls in. The installment examined the core conceptsof editing while exploredhow to enhance the GridView's editing undergo. In this installment we built upon the show created in the Customizing the Editing Interfacearticle and saw how to handle
ASP. NET 2.0 introduced a be of new Web controls designed for accessing and modifying data. These controls allow page developers to declaratively find and change data without writing anycode to perform the data find. This article is one in a series of articles on ASP. NET 2.0's new data source controls.
- explores the conceptsand advantages of data obtain controls and compares their usage in ASP. NET 2.0 to data access techniques in ASP. NET 1 x.
- shows how to use theSqlDataSource and AccessDataSource controls to ask data from a relational database.
- learn how toretrieve just a subset of database data based on hard-coded values and values from the querystring other Web controls on the page,session variables and so on.
- see howto acquire both remote and local XML data and show it in a data Web control.
- programmatically retrieve insert delete and update data using the SqlDataSource and AccessDataSource controls.
- hit the books the basics of updating database data using a SqlDataSource hold back. Also examines using the GridView to provide a web-based editing interface.
- see how tocustomize the GridView's columns to give a customized editing interface that includes enter validation and alternativeuser interface elements.
- investigate how toextend the GridView's customized editing interface to handle database NULL values.
Forex Groups - Tips on Trading
Related article:
http://aspnet.4guysfromrolla.com/articles/112807-1.aspx
comments | Add comment | Report as Spam
|