Custom Data Binding for Server Controls
page 6 of 7
by Justin Lovell
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 34653/ 79

Binding logic of the TitleDescriptionItem control

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 { }

View Entire Article

User Comments

Title: Great Article!   
Name: NiQuil
Date: 2010-01-18 9:53:29 AM
This helped me a lot! I am totally new to programming and this has been a great tutorial for me.
I am creating my own control library with databound controls, with XHTML output and taking into account the 125 (very) strict rules for the Dutch Government Guidelines for the web.

I noticed this is a Visual studio 2003 (?) project since I had to convert it to my 2008.

Isthis still "the way to go" on this subject, or have new developments, maybe on Microsoft's part, on this subject seen the light of day?

Kind regards,

Title: Why Doesn't It Work   
Name: Marc
Date: 2009-06-04 3:09:50 PM
My TitleDescriptionItems never display. CreateChildControlsnever gets hit. Why?
Title: DataSourceID   
Name: Andrew
Date: 2008-06-20 11:11:26 AM
Great article, however I was wondering how would one implement the DataSourceID and DataMember properties?

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024  |  Page Processed at 2024-05-24 11:56:44 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search