Presentation is loading. Please wait.

Presentation is loading. Please wait.

Listing 9.1 ShowLocalConnection.aspx

Similar presentations


Presentation on theme: "Listing 9.1 ShowLocalConnection.aspx"— Presentation transcript:

1 Listing 9.1 ShowLocalConnection.aspx
If you set the ConnectionString inside the SqlDataSource, then you need to repeat this string for EVERY data source. What if you need to take this to another computer with a different required connection string? You’ll need to change EVERY copy of the string!

2

3 Web.config File Instead, you can define your connection strings in the web.config file. Above are the first few lines of the web.config file. Web.config is an XML file. The root element is <configuration>. <connectionStrings> is a sub-element, and allows you to specify connection strings for any number of datbases using <add> elements.

4 Listing 9.5 ShowMovies.aspx
Using a connection string from the web.config file. You don’t have to change ShowMovies.aspx if you move it somewhere else. Just change the web.config file.

5

6 Listing 9.7 ShowInlineCommands.aspx
DELETE EDIT NEW

7 Listing 9.7 ShowInlineCommands.aspx
The buttons that appear in the DetailsView are based on these three properties.

8 The DetailsView and its associated SqlDataSource

9 Listing 9.7 ShowInlineCommands.aspx
By setting AutoGenerateRows to false, and defining a Fields collection composed of BoundField objects, you can control the displays that appear. BoundField properties: DataField – bind to column from query HeaderText – control the header that appears

10

11

12

13 Listing 9.9 ShowMovieCount.aspx

14 Stored Procedures are actual database objects (just like tables), stored in a DBMS (like SQL Server or Oracle). Stored procedures can perform multiple queries sequentially, apply conditional logic (like if-statements) , looping, and even recursion.

15

16 Listing 9.10 ShowFilterExpression.aspx
A FilterExpression can be used instead of a WHERE clause for a SelectCommand.

17

18 Listing 9.12 HandleError.aspx
Error-checking code Event gets triggered by a Select query taking place, and is handled by a C# event handler method.

19

20 Listing 9.13 GridViewHandleError.aspx
Error-checking code Event gets triggered by an Update attempt, and is handled by a C# event handler method.

21

22 Listing 9.14 CancelCommand.aspx

23

24 Listing 9.15 ShowDetailsView.aspx
If you want to start out in edit mode, set the DefaultMode property accordingly


Download ppt "Listing 9.1 ShowLocalConnection.aspx"

Similar presentations


Ads by Google