To specify the inheritance schema of the class

1. In the constructor, create an instance of the IDBWebDataLink (or IDBWebColumnLink) interface.

Note: You can use the existing DBWebControlDesigner as it relies only on the control having implemented one of the link interfaces.

2. Use the following code:

[Designer("Borland.Data.Web.DBWebControlDesigner"), ToolboxData("<{0}:MyControl runat=server></{0):MyControl>")]

public class MyControl:ListBox, IDBColumnLink, IPostBackDataHandler {

private DBWebColumnLink FColumnLink;

private IDBWebColumnLink IColumnLink;

FColumnLink = new DBWebColumnLink(this); IColumnLink = (FColumnLink as IDBWebColumnLink);

3. Override OnInit for handling postbacks.

protected override void OnInit(EventArgs e) {

  1. OnInit(e); if( Page != null )
  2. RegisterRequiresPostBack(this);

4. Override OnPreRender so it calls DataBind() before the control is rendered. Also, if the control is going to update a column value, then RegisterHiddenField needs to be called.

protected override void OnPreRender(EventArgs args) {

base.OnPreRender(args); Page.RegisterHiddenField(this.ID, IColumnLink.TableName + DBWebConst.

Splitter + IColumnLink.ColumnName);


5. Implement IPostBackHandler and in the LoadPostData event store the postCollection values for future use by the DBDataSource.

  • RaisePostDataChangedEvent is called prior to DataBind()
  • DataSet and related properties are NOT available here // Child controls are not available bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)

FColumnLink.LoadPostData(postDataKey, postCollection); return false;

void IPostBackDataHandler.RaisePostDataChangedEvent() {

6. Implement IDBWebDataLink, IDBWebColumnLink, and so-on, and provide public access methods to their properties:

Note: Specify the use of the Borland.Data.Web.TableNamePropEditor and Borland.Data.Web.ColumnNamePropEditor where appropriate.

string IDBWebDataLink.TableName {

return IDataLink.TableName;

IDataLink.TableName = value;

IDBDataSource IDBWebDataLink.DBDataSource {

return IDataLink.DBDataSource;

IDataLink.DBDataSource = value;

[Editor(typeof(Borland.Data.Web.TableNamePropEditor), typeof (UITypeEditor)), Category("DBWebControl"), DefaultValue(null)]

public string TableName {

return IDataLink.TableName;

IDataLink.TableName = value;


DesignerSerializationVisibility(DesignerSerializationVisibility. Hidden), DefaultValue(null)]

public IDBDataSource DBDataSource {

return IDataLink.DBDataSource; }

IDataLink.DBDataSource = value;

7. Implement DataBind().

public override void DataBind() {

// must be done first so DBDataSource setter is triggered. base.DataBind();

if( FColumnLink.IsDataBound )

// Figure what data you want to be put into the control.

8. Optionally, override the Render method. If all you only need to set the data from

DBDataSource settings, then you don't need to override Render. If you want to code special behavior, then you can override Render and write the output anyway you wish. Following is a sample used for the DBWebGrid so that a special grid is generated at design time when the properties for the IDBWebDataLink interface have not yet been set:

protected override void Render(HtmlTextWriter output) {

if( ClassUtils.IsDesignTime(Page) && !FDataLink.IsDataBound ) {

  1. EditItemIndex = 0;
  2. DataBind();
  3. RenderControl(output); }

else base.Render(output);

The DB Web Control is now extended.

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook

Post a comment