Composite inherited Datagrid control.

Discussion in 'ASP .Net Web Controls' started by Miles, Sep 8, 2005.

  1. Miles

    Miles Guest

    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.
     
    Miles, Sep 8, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sleigh
    Replies:
    1
    Views:
    2,736
    sleigh
    Feb 12, 2004
  2. Chad
    Replies:
    0
    Views:
    252
  3. Custom Composite Control inherited from TextBox

    , Oct 24, 2006, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    142
    John Saunders
    Oct 24, 2006
  4. Mike

    Composite vs non composite Controls

    Mike, Mar 10, 2005, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    290
    Sundararajan
    Mar 11, 2005
  5. 7stud --
    Replies:
    11
    Views:
    465
    7stud --
    Nov 9, 2007
Loading...

Share This Page