Adding Buttons to ASP Table rows in c#/ASP.NET

Discussion in 'C#' started by croker10, Sep 2, 2010.

  1. croker10

    croker10 New Member

    Joined:
    Sep 2, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi all,
    I am trying to create a table of user created filters for a data set and then display the filters in an ASP:Table. Displaying the filters works fine, and I have no problem there. The issue I am having is that the buttons I am trying to add are not adding in the way I think they should.

    I am setting the ID, Text, and OnClick events in my code behind in C#, but when I debug and view the source, the values have all been changed, and I can't understand why.

    The buttons need to be added, being called "buttonX" where X is the row number the button is in, so I can distinguish later to remove filters if the user clicks on them.

    If you think any other code would be helpful to figuring this out, I'd be happy to supply.

    Please let me know if you have any ideas, the code behind is here:

    Code:
     {
           Button b = new Button();
           b.OnClientClick = "delete_Item";
           b.ID = "delete" + count;
           b.Text = "Remove";
           b.Click +=new EventHandler(delete_Item);
    
           TableCell temp = new TableCell();
           temp.Controls.Add(b);
    
           r.Cells.Add(temp);
    
           filters.Rows.Add(r);
    
           count++;
    }
    And the html output is:


    Age Range25 - 36
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice