DataGrid extending with new/insert button

Discussion in 'ASP .Net Web Controls' started by Manuel Trunk, Nov 17, 2004.

  1. Manuel Trunk

    Manuel Trunk Guest

    Hi,
    I try to develop a server control which inherits from DataGrid and adds a
    new/insert button to this grid. This is no problem, but I can't get the event
    fired from this new button.
    I tried everything, implementing INamingContainer and IPostBackDataHandler,
    added the button to the footer of the datagrid and so on. Nothing works.
    Anyone who can help me?

    Kind regrads,
    Manuel
     
    Manuel Trunk, Nov 17, 2004
    #1
    1. Advertising

  2. Hi Manuel!

    I solved the same Problem.
    There is a LinkButton in the second column in the footer.
    Try:

    private void Page_Load(object sender, System.EventArgs e)
    {
    if(!IsPostBack)
    {
    DGDataBind();
    }
    else
    {
    Table tmp = (Table)DataGrid1.Controls[0];
    LinkButton btn = (LinkButton)tmp.Rows[tmp.Rows.Count -
    1].Cells[1].Controls[1];
    btn.Click += new System.EventHandler(this.cmdAddNew_Click);
    }
    }
    private void cmdAddNew_Click(object sender, System.EventArgs e)
    {
    //Your Event Code
    }
    private void DGDataBind()
    {
    //Your Binding Code
    }

    Wolfgang

    "Manuel Trunk" <Manuel > schrieb im
    Newsbeitrag news:...
    > Hi,
    > I try to develop a server control which inherits from DataGrid and adds a
    > new/insert button to this grid. This is no problem, but I can't get the
    > event
    > fired from this new button.
    > I tried everything, implementing INamingContainer and
    > IPostBackDataHandler,
    > added the button to the footer of the datagrid and so on. Nothing works.
    > Anyone who can help me?
    >
    > Kind regrads,
    > Manuel
    >
     
    Wolfgang Schwedhelm, Nov 18, 2004
    #2
    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. Replies:
    0
    Views:
    727
  2. Replies:
    1
    Views:
    5,803
  3. Manuel Trunk

    Extending datagrid with new/insert button

    Manuel Trunk, Nov 17, 2004, in forum: ASP .Net Building Controls
    Replies:
    6
    Views:
    147
    Manuel Trunk
    Nov 18, 2004
  4. Feege
    Replies:
    0
    Views:
    485
    Feege
    Dec 20, 2005
  5. Replies:
    2
    Views:
    485
    Thomas 'PointedEars' Lahn
    Mar 11, 2008
Loading...

Share This Page