We are eventually ending our ride down the hill. Basically, all the work has been done in the “basic” signature of the control. There are only two things that have to be done now.
One of the things that have to be done is override the DataBind method:
public override void DataBind() {
if (DataItem != null) {
Title = DataItem["Title"].ToString();
Description = DataItem["Description"].ToString();
}
}
Basically, we know what our transformed data source has – in other words, we know the columns that are located in the DataRow. That is about it… nothing else must be done to successfully data bind.
The other thing that is left on the agenda is performance. You might have noticed that there will be additional view state saved. That view state is from the controls inside the TitleDescriptionItem control. Because we do not need them to handle view state, we simply switch it off by overriding the EnableViewState property in the TitleDescriptionItem control:
public override bool EnableViewState {
get { return false; }
set { }
}