Datasheet
itemToSelect =
eventDurationDropDownList.Items.FindByValue(EventBeingEdited.EventDuration.ToString
())
itemToSelect.Selected = True
EventBeingEdited = Nothing
End Sub
The EventId is extracted from the URL parameters and used to create a new DiaryEvent object.
Populating the event text boxes is easy enough, but the details of time and duration of the event involve
populating the Hour and Minute drop-down boxes and ensuring the correct value is selected. This is
achieved by looping through hours from 0 to 23 and then minutes from 0 to 59. If the hour to be added
to the list is the same as the hour about to be added to the list box, make sure it’s the default selected
one. The same goes for the minute list box population.
Managing Contacts
Managing contacts is the last aspect of the Online Diary you’ll examine, and uses many of the same
principles as the other sections. YourContacts.aspx is the central contact management page. Here a list of
current contacts is displayed, and the option to add, edit, and delete contacts is possible.
All contacts are displayed using a
DataObjectSource and a GridView control; the principles being
identical to the displaying, deleting, and editing of the diary events. This time the
Contact class is used
for editing and display contact details, but otherwise the code is very similar to the events code.
The main page for displaying contacts is YourContacts.aspx, which contains a
GridView control in
which all current contacts are listed:
<asp:GridView ID=”GridView1” runat=”server” AutoGenerateColumns=”False”
CellPadding=”4”
DataSourceID=”ObjectDataSource1” ForeColor=”#333333” GridLines=”None”
Style=”z-index: 101;
left: 36px; position: absolute; top: 137px” DataKeyNames=”ContactId”>
<FooterStyle BackColor=”#5D7B9D” Font-Bold=”True” ForeColor=”White” />
<Columns>
<asp:CommandField ShowDeleteButton=”True” />
<asp:HyperLinkField DataNavigateUrlFields=”ContactId”
DataNavigateUrlFormatString=”~/SecureDiary/EditContact.aspx?ContactId={0}”
Text=”Edit” />
<asp:BoundField DataField=”LastName” HeaderText=”Last Name” />
<asp:BoundField DataField=”FirstName” HeaderText=”First Name” />
<asp:BoundField DataField=”Telephone” HeaderText=”Telephone” />
<asp:BoundField DataField=”Email” HeaderText=”Email Address” />
</Columns>
<RowStyle BackColor=”#F7F6F3” ForeColor=”#333333” />
<EditRowStyle BackColor=”#999999” />
<SelectedRowStyle BackColor=”#E2DED6” Font-Bold=”True”
ForeColor=”#333333” />
<PagerStyle BackColor=”#284775” ForeColor=”White”
HorizontalAlign=”Center” />
<HeaderStyle BackColor=”#5D7B9D” Font-Bold=”True” ForeColor=”White” />
<AlternatingRowStyle BackColor=”White” ForeColor=”#284775” />
</asp:GridView>
32
Chapter 1
04_749516 ch01.qxp 2/10/06 9:11 PM Page 32