Solved I just used asp:Repeater for the buttons, way more efficient.
I'm creating multiple tables with a foreach cycle and each table contains a button that leads to a separate page. Here's the html code for the button only.
<form name='input' action='AuctionDetails.aspx' method='get'>
<input type='submit' value='Bid now' name='{5}'/>
</form>
Now, I have a lot of iterations (around 50) and ALL of the buttons work, except the first one. Even when I filter the results (returns fewer tables), all of the buttons work, except the first one.
Here's the full method.
private void FillPageAuctions()
{
IEnumerable<AuctionClass> query = null;
var context = new AuctionsEntities();
string queryString = Request.QueryString.ToString();
if (Request.QueryString.ToString() != "")
{
query = from e in context.Auctions
where e.Category.Name == queryString
select e;
}
else
{
query = from e in context.Auctions select e;
}
StringBuilder sb = new StringBuilder();
if (query.Count() == 0)
{
sb.Append("There are no auctions in this category.");
}
else
{
foreach (AuctionClass auction in query)
{
string temp = auction.AuctionName;
if (auction.AuctionName.Length > 12)
{
temp = auction.AuctionName.Remove(12);
temp = temp + "...";
}
sb.Append(String.Format(@"<table style='border: 1px solid #666666;
float:left;
width: 24%;
margin: 0px 3px 3px 3px;
text-align: center;'>
<tr><th style='font-size: 18px'>{0}</th></tr>
<tr><td><img src='{1}' height='100px' width='100%'/></td></tr>
<tr><td>Price: ${2}</td></tr>
<tr><td>Time Left: </td></tr>
<tr><td>{3} hours</td></tr>
<tr><td>{4} minutes</td></tr>
<tr><td>
<form name='input' action='AuctionDetails.aspx' method='get'>
<input type='submit' value='Bid now' name='{5}'/>
</form>
</td></tr></table>", temp, "Untitled.png",
auction.CurrPrice, 0, 0, auction.AuctionID));
}
}
AuctionListLabel.Text = sb.ToString();
}