// These are methods/event handlers in the control // (TextBox in this example, although it doesn't matter) public void DataBind(DataTable dt, string column, int row) { this.m_BoundTable = dt; this.m_BoundColumn = column; this.m_BoundRow = row; } public void DataPostBack() { if (this.m_BoundTable != null && this.m_BoundTable.Rows.Count > this.m_BoundRow) if (this.m_BoundTable.Rows[this._BoundRow][this.m_BoundColumn].ToString() != this.Text) this.m_BoundTable.Rows[this._BoundRow][this.m_BoundColumn] = this.Text; } protected virtual void DataBindingHandler(object sender, System.EventArgs e) { if (this.m_BoundTable != null && this.m_BoundTable.Rows.Count > this.m_BoundRow) this.Text = this.m_BoundTable.Rows[this.m_BoundRow][this.m_BoundColumn].ToString(); }You use it like this:
this.txtMyTextBox.DataBind(MyDataTable, "MyColumn", 0); this.txtAgain.DataBind(Blah, "Blah", 0); Page.DataBind();The call to the Page's DataBind will cause the DataBindingHandler event handler to fire, which will fill your control's .Text so that it will display on your page.