Data binding A mechanism for displaying and modifying dynamic data from a Web page ASP.NET supports data binding Can point controls to database table as source fordata Displayed content drawn from table Interface for modifying data built into some controls(update, delete, insert) Data Binding Client Browser Web Server Default.aspx QuotesDatabase Data-binding Several ASP.NET controls designed to bindto data GridView Display/edit a database table as a grid Details View Display one table row at a time, insert new items Bulleted List Display a list of items from a table Many more … Sql Data Source control handles data retrieval,inserts, updates, and deletes Acts as bridge between database and data-bound control Contains SQL statements to perform database calls 1. Set page to Design mode2. Open Database Explorer3. Drag table onto page4. Select desired options5. Optionally Auto Format…6. Edit Columns and setID column Visible=false Generated Source “/> SQL Parameters SQL supports parameters to fill values in dynamically Microsoft? SQL Server™ syntax is @varname Before executing statement, parameters must be associated with values UPDATE Quotes SET Author=@Author WHERE ID=@ID How to associate parameters with Sql Data Source “Select Command=”SELECT [ID], [Author], [Quote] FROM [Quotes]“Update Command=”UPDATE Quotes SET Author=@Author, Quote=@Quote WHERE ID=@ID”Delete Command=”DELETE FROM Quotes WHERE ID=@ID”> Add Update and Delete commands with parameters List parameter names and types Note: Parameters should always be named the same as the corresponding column names to work properly with the Grid View and Details View controls.
Download Microsoft Visual C# 2005 ASP.NET 2.0 Data Binding.
0 comments:
Post a Comment