Adding dynamic LinkButton to dynamic table

Discussion in 'ASP .Net' started by =?Utf-8?B?QkxpVFpXaU5H?=, Jul 27, 2005.

  1. I have scoured the web to no avail. Any post that resembles my problem has no
    answer.

    I have an asp table on my page. I add rows and cells to it at run time with
    info provided from a database in a custom function. To one of those cells I
    add a new LinkButton, then wire a command event handler to it, which calls
    the custom function, thus bypassing any need to use IsPostBack.

    When a user clicks on the link button, nothing happens. I ran it through
    debug with breaks, and it doesn't even go through the event handler.

    So I tried a brand new blank page, and put a single linkbutton on it with an
    event handler and some test values. What I found disturbed me. The command
    and argument values are not stored in the resulting html! I'm at a loss to
    explain how a linkbutton works, but I feel this discovery is key to why mine
    aren't working.

    Anyone know why this happens? I'd really how linkbuttons work internally, so
    that I can better plan solutions. Am I simply doing something wrong?

    code:

    private void create_table()
    {
    r = new TableRow();
    c = new TableCell();
    LinkButton lb = new LinkButton();
    lb.ID = "lb_" + user_id;
    lb.Text = user_company_name;
    lb.CommandName = "SHOW_USER_DETAILS";
    lb.CommandArgument = user_id;
    lb.Command += new
    System.Web.UI.WebControls.CommandEventHandler(this.lb_show_user_details_Command);
    c.Controls.Add(lb);
    r.Cells.Add(c);
    table1.Rows.Add(r);
    }
     
    =?Utf-8?B?QkxpVFpXaU5H?=, Jul 27, 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. Felipe Garcia
    Replies:
    1
    Views:
    5,914
    ElmoWatson
    Aug 28, 2003
  2. Vaibhav
    Replies:
    0
    Views:
    497
    Vaibhav
    Aug 28, 2003
  3. Sathyaish
    Replies:
    3
    Views:
    3,131
    Sathyaish
    Sep 8, 2005
  4. Sathyaish

    Linkbutton does not look like a linkbutton

    Sathyaish, Sep 8, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    201
    Sathyaish
    Sep 8, 2005
  5. Martin Strojek

    Problem adding dynamic LinkButton[] Array with event to a page

    Martin Strojek, Nov 9, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    366
    Martin Strojek
    Nov 9, 2004
Loading...

Share This Page