« Home « Chủ đề ASP.NET Configuration

Chủ đề : ASP.NET Configuration


Có 100+ tài liệu thuộc chủ đề "ASP.NET Configuration"

ASP.NET 4 Unleased - p 83

tailieu.vn

ptg The ObjectDataSource control includes a DataObjectTypeName property. If you have the need, you can get around this limitation by handling the Inserting , Updating , or Deleting event. When you handle one of these events, you can pass any object that you need to a method. Paging, Sorting, and Filtering Data with the ObjectDataSource Control. The ObjectDataSource control provides...

ASP.NET 4 Unleased - p 84

tailieu.vn

ptg When you open the page in Listing 18.20, the GridView displays its paging interface,. which you can use to navigate between different pages of records (see Figure 18.5).. FIGURE 18.5 Displaying multiple pages with data source paging.. The modified stored procedure in Listing 18.24 does the same thing as the stored procedure in Listing 18.23. LISTING 18.24 GetPagedMovies2005.sql CREATE...

ASP.NET 4 Unleased - p 85

tailieu.vn

ptg 814 CHAPTER 18 Using the ObjectDataSource Control. LISTING 18.30 ShowFilteredMovies.aspx. Page Language=”C#” %>. “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <form id=”form1” runat=”server”>. <asp:DropDownList. id=”ddlMovieCategory”. Runat=”server” />. <asp:Button id=”btnSelect”. <asp:GridView id=”grdMovies”. Runat=”server”>. <asp:BoundField DataField=”Title”. HeaderText=”Movie Title” />. <asp:BoundField. HeaderText=”Movie Director” />. </asp:GridView>. <asp:ObjectDataSource id=”srcMovieCategories”. <asp:ObjectDataSource id=”srcMovies”. <asp:ControlParameter Name=”Category”. ControlID=”ddlMovieCategory” />. </asp:ObjectDataSource>. Both ObjectDataSource controls in Listing 18.30 have caching...

ASP.NET 4 Unleased - p 86

tailieu.vn

ptg In Listing 18.34, the Inserted event handler checks for an exception. exists, the exception is handled and an error message displays (see Figure 18.10).. The page in Listing 18.34 is bound to the component in Listing 18.35.. LISTING 18.35 InsertMovie.cs using System;. using System.Web;. using System.Data;. using System.Data.SqlClient;. using System.Web.Configuration;. FIGURE 18.10 Handling method errors gracefully.. cmd.Connection = con;....

asp.net 4 unleased - p 87

tailieu.vn

LISTING 18.41 ShowMovieDataSource.aspx. Page Language=”C#” %>. Register TagPrefix=”custom” Namespace=”AspNetUnleashed.Samples” %>. “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <form id=”form1” runat=”server”>. <asp:GridView id=”grdMovies”. Runat=”server” />. <custom:MovieDataSource id=”srcMovies”. FIGURE 18.11 Using the MovieDataSource control to display movies.. directive at the top of Listing 18.41. The standard DataSource Parameter objects included in the ASP.NET Framework enable you to represent objects such as query...

ASP.NET 4 Unleased - p 88

tailieu.vn

ptg You also learn how to build Microsoft SQL Server database objects, such as stored proce-. dures and user-defined types, by using .NET Framework. For example, you learn how to write a Microsoft SQL Server stored procedure, using C# programming language.. If you don’t want to get your hands dirty touching any actual SQL or ADO.NET code, skip this chapter...

ASP.NET 4 Unleased - p 89

tailieu.vn

BuffersReceived —Returns the number of TDS packets received.. BuffersSent —Returns the number of TDS packets sent.. BytesReceived —Returns the number of bytes received.. BytesSent —Returns the number of bytes sent.. ConnectionTime —Returns the total amount of time that the connection has been opened.. CursorsOpen —Returns the number of cursors opened.. ExecutionTime —Returns the connection execution time in milliseconds.. IduCount —Returns...

ASP.NET 4 Unleased - p 90

tailieu.vn

The second statement adds a SqlParameter to the SqlCommand object’s Parameters collec- tion. @Title = N’ASP.NET 4.0 Unleashed’. The SqlCommand object calls the sp_executesql stored procedure when it executes a command. In this case, it passes the type, size, and value of the @Title parameter to the sp_executesql stored procedure.. the SqlCommand object infers the type and size of the...

ASP.NET 4 Unleased - p 91

tailieu.vn

If you need to return a single value from a database query, you can use the. This method always returns the value of the first column from the first row of a resultset. Even when a query returns hundreds of columns and billions of rows, everything is ignored except for the value of the first column from the first row.....

ASP.NET 4 Unleased - p 92

tailieu.vn

DataLayer1.Movie newMovie = new DataLayer1.Movie();. movies.Add(newMovie);. WebConfigurationManager.ConnectionStrings[“Movies”].ConnectionString;. In Listing 19.22, it is assumed that there is both a movies category and movies resultset.. The page in Listing 19.23 displays the contents of the two database tables in two GridView controls (see Figure 19.10).. FIGURE 19.10 Displaying two resultsets.. LISTING 19.23 ShowDataLayer1.aspx. Page Language=”C#” %>. Import Namespace=”System.Collections.Generic” %>. “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>. <script runat=”server”>....

ASP.NET 4 Unleased - p 93

tailieu.vn

if (dtblMovies.Rows[i][“Title. txtTitle.Text) dtblMovies.Rows[i][“Title. txtTitle.Text;. if (dtblMovies.Rows[i][“Director. txtDirector.Text) dtblMovies.Rows[i][“Director. txtDirector.Text;. lblResults.Text = String.Format(“Updated {0} rows”, numUpdated);. <html xmlns=”http://www.w3.org/1999/xhtml” >. <form id=”form1” runat=”server”>. <asp:Repeater id=”rptMovies”. Runat=”server”>. <asp:TextBox id=”txtTitle”. Text=’<%#Eval(“Title”)%>’. Runat=”server” />. <asp:TextBox. id=”txtDirector”. Text=’<%#Eval(“Director”)%>’. </asp:Repeater>. <asp:LinkButton id=”lnkUpdate”. Runat=”server” OnClick=”lnkUpdate_Click” />. <asp:Label. id=”lblResults”. The SqlDataAdapter in Listing 19.27 performs a batch update. Using the DataTable Object. The DataTable object represents an in-memory...

asp.net 4 unleased - p 94

tailieu.vn

LISTING 19.31 ShowMovie9.aspx. Page Language=”C#” %>. Import Namespace=”System.Data” %>. “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>. <script runat=”server”>. <html xmlns=”http://www.w3.org/1999/xhtml” >. FIGURE 19.16 Tracking data row changes.. <head id=”Head1” runat=”server”>. <form id=”form1” runat=”server”>. <asp:GridView id=”grdMovies”. Runat=”server”>. <asp:TemplateField>. </asp:TemplateField>. </asp:GridView>. <asp:Button id=”btnReject”. Runat=”server” />. <asp:Button id=”btnAccept”. <asp:ObjectDataSource id=”srcMovies”. Using the DataView Object. The page in Listing 19.30 illustrates one way that you can use a DataView ....

ASP.NET 4 Unleased - p 95

tailieu.vn

Using Asynchronous ASP.NET Pages. When you take advantage of asynchronous ADO.NET methods, you must also enable asynchronous ASP.NET page execution. You enable an asynchronous ASP.NET page by adding the following two attributes to a page directive:. Page Async=”true” AsyncTimeout=”8” %>. The timeout value specifies the amount of time that the page gives a set of asynchronous tasks to complete before...

ASP.NET 4 Unleased - p 96

tailieu.vn

After you have loaded the DBMovie assembly, you can create a new user-defined type from the assembly. Execute the following command:. CREATE TYPE dbo.DBMovie EXTERNAL NAME DBMovie.DBMovie. If you need to delete the type, you can execute the following command:. After you have added the type, you can use it just like any other SQL Server native type.. For example,...

ASP.NET 4 Unleased - p 97

tailieu.vn

ptg 934 CHAPTER 19 Building Data Access Components with ADO.NET. This chapter provided you with an overview of ADO.NET. It described how you can use ADO.NET to represent database data with both a connected and disconnected model of data access.. In the first part, you learned how to use the Connection , Command , and DataReader objects to connect to...

ASP.NET 4 Unleased - p 98

tailieu.vn

You write the GetListFromCommand() method as a generic method once, and you can use the method with any type that meets the generic constraints in the future.. You can use generics to define a certain pattern of code into which you can plug a particular type.. Lambda expressions, another language feature introduced with .NET Framework 3.5, provide you with an...

ASP.NET 4 Unleased - p 99

tailieu.vn

Name —Indicates the name of the database table that corresponds to the class.. If you don’t do this, LINQ to SQL checks whether the values of all the properties match the values of all the columns before performing an update command to prevent concurrency conflicts. If you specify a version property, LINQ to SQL can check the value of this...

ASP.NET 4 Unleased - p 100

tailieu.vn

Performing Standard Database Commands with LINQ to SQL. In this section, you learn how to use LINQ to SQL as a replacement for working directly with SQL. We start by discussing how LINQ to SQL queries differ from standard LINQ queries. Next, we examine how you can perform standard database queries and commands using LINQ to SQL such as Select,...

ASP.NET 4 Unleased - p 101

tailieu.vn

ptg The page in Listing 20.23 contains a FormView control and a GridView control. You can. The FormView control is bound to an ObjectDataSource control that represents the Movie class.. LISTING 20.23 Standard\InsertMovie.aspx. Page Language=”C#” Trace=”true” %>. “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>. <html xmlns=”http://www.w3.org/1999/xhtml”>. <head runat=”server”>. <form id=”form1” runat=”server”>. <asp:FormView id=”frmMovie”. Runat=”Server”>. <asp:Label id=”lblTitle”. Text=”Title:”. Runat=”server” />. <asp:TextBox id=”txtTitle”. Text=’<. Bind(“Title”) %>’. <asp:Label. id=”lblCategory”....

ASP.NET 4 Unleased - p 102

tailieu.vn

ptg You can build LINQ to SQL query expressions dynamically by taking advantage of the. System.Linq.Expressions.Expression class. Add() —Creates an expression that represents addition.. And() —Creates an expression that represents a logical AND.. Condition() —Creates an expression that represents a condition.. Constant() —Creates an expression that represents a constant value.. Convert() —Creates an expression that represents a conversion from one...