Displaying a Record with a DetailsView Control in .NET framework
Displaying a Record with a DetailsView Control Barcode Generator In .NET Framework Using Barcode generation for ASP.NET Control to generate, create bar code image in ASP.NET applications. If you want to display a single record of data in a table form with the field names in the left column and the field data in the right column, then the DetailsView control is for you Creating UPC Code In C# Using Barcode drawer for .NET Control to generate, create UCC - 12 image in .NET framework applications. Displaying a Record with a DetailsView Control
Making UPCA In .NET Using Barcode generation for .NET Control to generate, create UPCA image in VS .NET applications. If you want to just display data without editing, the DetailsView control requires very little work In fact, you don t even have to provide any functions; you can set everything up strictly declaratively, which is incredibly cool because it leaves little room for errors! To create a simple example, I started out with a fresh page, and dropped a SqlDataSource and a DetailsView control onto it I then opened the Configure Data Source dialog box from the SqlDataSource control s Smart Tag (I used a connection string that I created in Listing 4-1, earlier in this chapter, although you re free to create a new one or use an existing one) I specified the table, customers, and all the fields (the star (*) symbol) I clicked Next and Finish, and that was it I had the data source set up Setting up the DetailsView was just as easy I dropped it in on the form, and opened the control s Smart Tag; I then selected its data source, as shown in Figure 4-1 UPC Code Printer In VB.NET Using Barcode printer for .NET Control to generate, create UPCA image in .NET framework applications. Book VI 4
Bar Code Generation In .NET Using Barcode maker for ASP.NET Control to generate, create barcode image in ASP.NET applications. Displaying and Editing Detail Data
Bar Code Drawer In VS .NET Using Barcode generation for ASP.NET Control to generate, create barcode image in ASP.NET applications. Figure 4-1: Use the Smart Tag to choose the data source for a Details View control
EAN128 Encoder In Visual C# Using Barcode printer for VS .NET Control to generate, create EAN / UCC - 14 image in .NET applications. As soon as I selected the data source, the DetailsView control updated its display, showing the columns in the data source, as shown in Figure 4-2 Recognizing Code-128 In .NET Using Barcode reader for VS .NET Control to read, scan read, scan image in VS .NET applications. Figure 4-2: The Details View control automatically updated its appearance after receiving its data source Encode UPC - 13 In VB.NET Using Barcode drawer for .NET Control to generate, create EAN-13 Supplement 5 image in .NET applications. Next I saved my form (any name works), ran it in the browser, and Shazam! It worked! Check out Figure 4-3 to see the form in my browser It s not the prettiest UPC-A Generator In .NET Using Barcode drawer for Visual Studio .NET Control to generate, create UPC-A Supplement 5 image in VS .NET applications. Displaying a Record with a DetailsView Control
Create Data Matrix 2d Barcode In .NET Framework Using Barcode maker for Visual Studio .NET Control to generate, create Data Matrix ECC200 image in .NET applications. (it could use some formatting), but it s pretty good considering I didn t have to do any programming to get there Barcode Drawer In .NET Framework Using Barcode encoder for Visual Studio .NET Control to generate, create barcode image in .NET applications. Figure 4-3: The Details View control was easy to set up and use
USS Code 39 Printer In .NET Using Barcode generator for .NET framework Control to generate, create Code-39 image in .NET applications. Even though I didn t do any programming in this case, Visual Studio created a certain amount of code for me This, of course, is all declarative, as I didn t have to provide any functions Listing 4-2 shows the code that Visual Studio has created EAN13 Creation In Visual C# Using Barcode generation for VS .NET Control to generate, create GS1 - 13 image in Visual Studio .NET applications. Listing 4-2: A page that uses a DetailsView control (VB) Printing UCC-128 In VB.NET Using Barcode encoder for Visual Studio .NET Control to generate, create EAN 128 image in .NET applications. <%@ Page Language= VB %> <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 10 Transitional//EN http://wwww3org/TR/xhtml1/DTD/xhtml1-transitionaldtd > <script runat= server > </script> <html xmlns= http://wwww3org/1999/xhtml > <head runat= server > <title>Untitled Page</title> </head> <body> <form id= form1 runat= server > <div> <asp:SqlDataSource ID= SqlDataSource1 runat= server ConnectionString= <%$ ConnectionStrings:ASPDConnectionString %> SelectCommand= SELECT * FROM [customers] ></asp:SqlDataSource> <asp:DetailsView ID= DetailsView1 runat= server AutoGenerateRows= False DataKeyNames= id DataSourceID= SqlDataSource1 Height= 50px Width= 125px > <Fields> <asp:BoundField DataField= id HeaderText= id InsertVisible= False ReadOnly= True SortExpression= id /> <asp:BoundField DataField= first_name HeaderText= first_name SortExpression= first_name /> <asp:BoundField DataField= last_name HeaderText= last_name SortExpression= last_name /> Print Code39 In Java Using Barcode creator for Java Control to generate, create Code39 image in Java applications. Displaying a Record with a DetailsView Control
Printing EAN / UCC - 13 In .NET Using Barcode printer for VS .NET Control to generate, create UCC - 12 image in .NET framework applications. <asp:BoundField DataField= phone HeaderText= phone SortExpression= phone /> <asp:BoundField DataField= credit HeaderText= credit SortExpression= credit /> <asp:BoundField DataField= address HeaderText= address SortExpression= address /> <asp:BoundField DataField= city HeaderText= city SortExpression= city /> <asp:BoundField DataField= state HeaderText= state SortExpression= state /> </Fields> </asp:DetailsView> </div> </form> </body> </html> Barcode Maker In VB.NET Using Barcode drawer for .NET framework Control to generate, create bar code image in .NET applications. Book VI 4
Barcode Printer In Java Using Barcode creator for Java Control to generate, create bar code image in Java applications. Remember, as with any ASPNET application, you re free to type this code in manually, or you can let the designer create it for you Either way, however, you should make sure you understand what the code does so you can modify and enhance it The heart of this code is inside the <div> tag, and the code consists of two parts, the SqlDataSource control and the DetailsView control The SqlDataSource control here just includes a connection string reference and a select statement to obtain the data The DetailsView control includes the required ID and runat tags Additionally, it contains the following properties: AutoGenerateRows: This is set to false because inside the DetailsView tag are tags specifying the individual fields from which to access the data (Remember, the designer did all this for us) DataSourceID: This is the ID of the data source I added in the designer Height and Width: This is just the size of the control in the Web page Additionally, the DetailsView control contains a field called DataKeyNames This is a string that represents the name of the primary key field in the data source The designer added this field automatically, although it s not used in this example (It s used when you edit data; it lets the UPDATE, INSERT, and DELETE SQL statements know which row of data to modify) After the properties come the Field tags These tags specify exactly what fields you want to appear in the form Now if you ve read other portions of this book, you might be able to predict what I m about to say The terminology used in NET isn t particularly consistent These Field tags are not fields in the data set; they are fields on the form Each field tag does, however, get its data from a particular column in the data set Encode Barcode In .NET Using Barcode creator for Visual Studio .NET Control to generate, create bar code image in .NET framework applications. |
|
|
|
| ALL RIGHTS RESERVED. Business Refinery (c) 2006 - 2010. | Terms of Use | Privacy Policy |