Summary


In this hour we looked at how to edit, delete, and insert data into a database through an ASP.NET page. Like displaying data, modifying a database's content through a web page involves both a data source control and a data Web control. To insert, update, or delete data, we need to configure the SqlDataSource control to generate the appropriate INSERT, UPDATE, and DELETE statements, which can be accomplished by checking the appropriate check box in the wizard.

When the SqlDataSource has been configured correctly, adding, editing, and deleting support with the GridView is as simple as binding the GridView to the data source control and checking the Enable Deleting and Enable Editing check boxes in the smart tag. At a bare minimum, this is all that is needed to implement deleting and editing of the GridView's underlying data. However, often we'll want to customize the Edit or Delete field or tweak the editing interface. These tasks, though, are not difficult, require zero source code, and can be accomplished through Visual Web Developer's Design view. If more advanced logic is required when updating or deleting a GridView's data, a number of related events are fired during the updating and deleting processes. (See the exercises section for practice on one of these GridView events.)

This hour concluded with a look at using the DetailsView to insert new records into the underlying database table. Creating an insertable DetailsView involved the same steps as creating an editable or deletable GridView. Additionally, the DetailsView provides similar mechanisms for customizing the insertable interface as the GridView does for customizing the editable interface.

In this hour and the preceding one, we examined how to display and modify database data using the GridView and DetailsView controls. In the next hour we'll look at binding database data to DropDownList, RadioButtonList, and CheckBoxList controls, and we'll also illustrate how to use the DropDownList and GridView Web controls in conjunction to provide filtering of data.




Sams Teach Yourself ASP. NET 2.0 in 24 Hours, Complete Starter Kit
Sams Teach Yourself ASP.NET 2.0 in 24 Hours, Complete Starter Kit
ISBN: 0672327384
EAN: 2147483647
Year: 2004
Pages: 233

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net