Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Build Your Own ASP.NET 2.0 Web Site Using CSharp And VB (2006) [eng]-1.pdf
Скачиваний:
142
Добавлен:
16.08.2013
Размер:
15.69 Mб
Скачать

Chapter 11: Managing Content Using Grid View and Details View

In the last part of employeeDetails_ItemUpdating, we rebind both the GridView and the DetailsView with the updated information, and switch the DetailsView back to its read-only state:

Visual Basic

File: AddressBook.aspx.vb (excerpt)

'Exit edit mode employeeDetails.ChangeMode(DetailsViewMode.ReadOnly)

'Reload the employees grid

BindGrid()

' Reload the details view BindDetails()

C#

File: AddressBook.aspx.cs (excerpt)

//Exit edit mode employeeDetails.ChangeMode(DetailsViewMode.ReadOnly);

//Reload the employees grid

BindGrid();

// Reload the details view BindDetails();

The code is ready to be executed now! Try updating the addresses of your employees to ensure the feature works correctly—it should display as shown in Figure 11.18.

Summary

As we’ve seen throughout this chapter, GridViews and DetailsViews provide enormous flexibility and power in terms of presenting database data dynamically within the browser. In these pages, we learned how to create both of these data controls and bind data to them. We also learned how to customize the appearance of elements using templates and styles, and saw how various commands allow us to select and update items. You can use these techniques to add new records, and update existing ones.

The next chapter will begin to introduce you to advanced programming topics, as we investigate even more possibilities for data binding the DetailsView control to allow for the editing, updating, and insertion of new records with minimal coding effort. We’ll also have a chance to explore the topic of code-free data binding in that chapter.

468