Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8821621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:54:05+00:00 2026-06-14T05:54:05+00:00

I have this code below that create rows and cells for a list of

  • 0

I have this code below that create rows and cells for a list of products. There is a button that I want to use to get additional product information. Basically the user will search for something and it will display limited results. When the user clicks on the button it will call a method that will do something else.

How do I get that button to pass and ID or something to a method?

I tried the .Click but did not work to call the method. Currently the method only displays a messagebox.

for (rowCtr = 1; rowCtr <= rowCnt; rowCtr++)
{
    // Create new row and add it to the table.
    TableRow tRow = new TableRow();
    Table1.Rows.Add(tRow);
    for (cellCtr = 1; cellCtr <= cellCnt; cellCtr++)
    {
        // Create a new cell and add it to the row.
        TableCell tCell = new TableCell();

        if (rowCtr == 1 && cellCtr == 1)
        {
            Image ProductImage = new Image();
            ProductImage.Height = 75;
            ProductImage.Width = 75;
            tCell.RowSpan = 5;
            tCell.Controls.Add(ProductImage);
            tRow.Cells.Add(tCell);
        }

        if (rowCtr == 1 && cellCtr == 2)
        {
            tCell.Text = "Title: Title of Product";
            tRow.Cells.Add(tCell);
        }

        if (rowCtr == 2 && cellCtr == 2)
        {
            tCell.Text = "Weight (lbs): 54";
            tRow.Cells.Add(tCell);
        }

        if (rowCtr == 4 && cellCtr == 2)
        {
            Button getOfferButton = new Button();
            getOfferButton.Width = 100;
            getOfferButton.Text = "Get Offer";
            getOfferButton.Click += new EventHandler(getOffer);
            tCell.Controls.Add(getOfferButton);

            tRow.Cells.Add(tCell);
        }

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:54:07+00:00Added an answer on June 14, 2026 at 5:54 am

    I think you should be using <asp:GridView /> control instead of generating this with markup. One way to handle this is use the OnCommand event and pass the ID as argument

    getOfferButton.Click += new CommandEventHandler(RowButton_OnCommand);
    getOfferButton.CommandArgument = "123";
    

    and then the Handler

    protected void RowButton_OnCommand(object sender, CommandEventArgs e)
    {
       string id = e.CommandArgument.ToString(); //could convert this to integer
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this javascript code below that uses jquery, it is suppoed to be
I have a data that looks like this . And my code below simply
I have a code like this below, which gives me a $link that equals
I have this code below. I need to use a class id instead of
I have this snippet of code below. I want to pass the value of
Suppose I have this database table (some sample code below) that stores the relationship
I have this code below. As you can see I am passing two variables
I have this code below: $insert = array(); for ($i = 1, $n =
I have this below code and it work fine header (content-type: text/xml); $xml =
I have this kind of code below, how can I bind the visibility of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.