Composite inherited Datagrid control.

M

Miles

I want to expand the standard ASP.Net Datagrid so I have a class that
inherits from it...

public class MyDataGrid : System.Web.UI.WebControls.DataGrid, INamingContainer

I want to add a control after the footer when the enhanced datagrid control
is rendered. This control is a button so I added it in the following
override...

protected override void CreateChildControls()
{
base.CreateChildControls ();

//cmdAddToList declared at class scope
cmdAddToList = new Button();
cmdAddToList.ID = "cmdAddToList";
cmdAddToList.Text = "Add to List";
cmdAddToList.Click += new EventHandler(cmdAddToList_Click);
this.Controls.Add(cmdAddToList);
}

And the Render is overridden as per MSDN...

protected override void Render(HtmlTextWriter writer)
{
this.EnsureChildControls();
base.Render(writer);
}

Problem is, the button control is not added. If a postback is done by
another standard control on the datagrid then is appears!

Any clues qould be appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top