Wei-Meng Lee - C# 2008 Programmer's Reference

Здесь есть возможность читать онлайн «Wei-Meng Lee - C# 2008 Programmer's Reference» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Город: Indianapolis, Год выпуска: 2009, ISBN: 2009, Издательство: Wiley Publishing, Inc., Жанр: Программирование, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

C# 2008 Programmer's Reference: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «C# 2008 Programmer's Reference»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

C# 2008 Programmers Reference provides a concise and thorough reference on all aspects of the language. Each chapter contains detailed code samples that provide a quick and easy way to understand the key concepts covered.

C# 2008 Programmer's Reference — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «C# 2008 Programmer's Reference», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

EnableInsert="True"

EnableUpdate="True"

TableName="titles">

Select the GridViewcontrol's SmartTag, and check the five checkboxes (see Figure 17-11).

Figure 1711 This makes the GridViewlook like Figure 1712 The column names - фото 298

Figure 17-11

This makes the GridViewlook like Figure 17-12. The column names are now clickable and that new column containing Edit, Delete, and Select is added to the GridViewcontrol. Also, paging is now enabled (located at the bottom of the GridViewcontrol).

Figure 1712 Click the Auto Format link in the SmartTag of the - фото 299

Figure 17-12

Click the Auto Format link in the SmartTag of the GridViewcontrol, and select the Sand and Sky scheme.

The GridViewcontrol contains all the fields of the titlestable, but there are some that you don't really need. So select the notescolumn, and remove it by choosing Remove Column from GridView Tasks (see Figure 17-13). Delete the advance, royalty, and ytd_salescolumns as well.

Figure 1713 The GridView control should now look like Figure 1714 - фото 300

Figure 17-13

The GridView control should now look like Figure 17-14.

Figure 1714 Now to debug the application press F5 You are asked to modify - фото 301

Figure 17-14

Now, to debug the application, press F5. You are asked to modify the Web.configfile for debugging; click OK. You also are prompted that script debugging is disabled in Internet Explorer; click Yes to continue debugging.

Figure 17-15 shows the GridViewcontrol displaying the rows in the titles table. You can sort the rows by clicking on the column headers, and edit and delete records.

Figure 1715 Displaying Publishers Name As Figure 1715 shows the - фото 302

Figure 17-15

Displaying Publisher's Name

As Figure 17-15 shows, the publisher's ID appears in the GridViewcontrol under the pub_idfield. It would be helpful to the user if the publisher's name displayed instead of its ID. To do that, switch to the source view of Default.aspxand within the element, replace the following element:

DataField="pub_id"

HeaderText="pub_id"

SortExpression="pub_id"/>

with this:

HeaderText="Publisher">

Essentially, this changes the header for the publisher column in the GridView to Publisher, and the values are now derived from the publisher.pub_nameproperty of the DataClassesDataContextclass.

Press F5 to debug the application again to see the publishers' names instead of the publishers' IDs (see Figure 17-16).

Figure 1716 Displaying Titles from a Selected Publisher So far all the - фото 303

Figure 17-16

Displaying Titles from a Selected Publisher

So far, all the titles in the titlestable are displayed in the GridViewcontrol. You might want to restrict the titles displayed to a particular selected publisher. To do so, insert another LinqDataSourcecontrol to the Default.aspxpage by adding the following highlighted code:

ID="LinqDataSource1"

runat="server"

ContextTypeName="DataClassesDataContext"

EnableDelete="True"

EnableInsert="True"

EnableUpdate="True"

TableName="titles">

ID="LinqDataSource2"

runat="server"

ContextTypeName="DataClassesDataContext"

OrderBy="pub_name"

Select="new(pub_name, pub_id)"

TableName="publishers">

Notice that the second LinqDataSourcecontrol has the Selectattribute where you can specify the name of the fields you want to retrieve ( pub_nameand pub_id, in this example).

Add a DropDownListcontrol to the top of the page by adding the following highlighted code:





Display titles by publisher:

ID="DropDownList1"

runat="server"

DataSourceID="LinqDataSource2"

DataTextField="pub_name"

DataValueField="pub_id"

AutoPostBack="True">

...

...

This addition binds a DropDownListcontrol to the LinqDataSourcecontrol. The DropDownListcontrol will display the list of publisher names ( pub_name), and each publisher's name has the pub-idas its value.

Default.aspxshould now look like Figure 17-17 in design view. You will see the text "Display titles by publisher:" as well as a dropdown list control.

Figure 1717 To configure the first LinqDataSourcecontrol so that the - фото 304

Figure 17-17

To configure the first LinqDataSourcecontrol so that the GridView control will only display titles from the selected publisher, click on the SmartTag of the GridViewcontrol, and click the Configure Data Source link (see Figure 17-18).

Figure 1718 Click Next and then click the Where button Enter the following - фото 305

Figure 17-18

Click Next, and then click the Where button. Enter the following values in the dialog (see Figure 17-19).

Condition Value
Column pub_id
Operator ==
Source Control
Control ID DropDownList1
Figure 1719 Click Add OK and then Finish Visual Studio 2008 will ask if - фото 306

Figure 17-19

Click Add, OK, and then Finish. Visual Studio 2008 will ask if you want to regenerate the GridView columns fields and data keys. Click No.

This will make the GridViewcontrol display titles whose pub_idfile match the pub-idvalue of the selected publisher in the DropDownList1control.

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «C# 2008 Programmer's Reference»

Представляем Вашему вниманию похожие книги на «C# 2008 Programmer's Reference» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «C# 2008 Programmer's Reference»

Обсуждение, отзывы о книге «C# 2008 Programmer's Reference» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x