15.02.2015 Views

C# 4 and .NET 4

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1180 ❘ ChaPTer 40 cOre Asp.net<br />

Here you have added a new table row containing a table with a ListView control in one column <strong>and</strong> a<br />

FormView control in the other.<br />

The ListView uses to output a bulleted list <strong>and</strong> <strong>and</strong><br />

to display event details as list items. In , a container<br />

element for items is specified with a PlaceHolder control that has the ID=“itemPlaceholder”<br />

attribute. To facilitate selection, you raise a Select comm<strong>and</strong> from the event name link rendered in<br />

, which automatically changes the selection. You also use the OnSelectedIndexChanged<br />

event, triggered when the Select comm<strong>and</strong> changes the selection, to ensure that the list display updates<br />

itself to display the selected item in a different style. The event h<strong>and</strong>ler for this is shown in the<br />

following code:<br />

protected void EventList_SelectedIndexChanged(object sender, EventArgs e)<br />

{<br />

EventList.DataBind();<br />

}<br />

You also need to ensure new events are added to the list:<br />

if (queryResult == 1)<br />

{<br />

resultLabel.Text = "Event Added.";<br />

EventData = null;<br />

calendar.SelectedDate =<br />

GetFreeDate(calendar.SelectedDate.AddDays(1));<br />

GridView1.DataBind();<br />

EventList.DataBind();<br />

}<br />

Now selectable event details are available in the table, as shown in Figure 40-14.<br />

There is much more that you can do with templates <strong>and</strong> data-bound controls in general, enough in fact to<br />

fill a whole book. However, this should be enough to get you started with your experimentation.<br />

figure 40-14<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!