Displaying ListView items - with class! by Rob Birdwell
PersonListView.InsertItem(PersonListView.ListItems.Count,
new PersonListItem(new Person("Bill Gates", "Chairman & CSA", "987654")));
PersonListView.InsertItem(PersonListView.ListItems.Count,
new PersonListItem(new Person("George Bush", "Commander-In Chief", "9999")));
}
The benefits of having a PersonListItem sub-class should be obvious - when a user clicks on an item, we have access to all the class data - not just the ListItem.Text property or sub-item data! Here's a sample event handler for our PersonListView's SelectedIndexChanged event:
protected void PersonListView_SelectedIndexChanged (object sender, Syste
| 对此文章发表了评论 |

