SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Sep 2008
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Creating asp buttons programmatical from a loop

    Hi

    I am using vb.net

    I am building a table, I am doing this programatically using a string builder. There could be multiple rows to this table.

    In the last column of this table I would like to place a asp button control for each row. How could I do this?

    I would also like to add a click event for these buttons. Each row has a unique value, I would like the event to get this value and perform further actions with it.

    I do not wish to use a Datagrid etc etc.. There are good reasons for building it this way.

    Please advise

  2. #2
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,649
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    There probably aren't good reasons why you are building this this way. What are those reasons?

    Anyhow, if you are just dumping a string into the browser, you really can't add controls. Now, if you were dynamically building ASP.NET table rows/cells, you could add the button to the cell's controls collection.

  3. #3
    SitePoint Member
    Join Date
    Sep 2008
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The reason I feel this is the best way to create this table is because there are certain checks that are done for each item in almost all the columns, depending on the outcome of what is in the column will determine what goes in there. Before each row is created there is also a test done whic determines the css, and on some of the cells this is repeated.

  4. #4
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,649
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    You know you can set all that in your gridview template, rather than building a big, hard to maintain string behind the curtain.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •