By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,829 Members | 1,828 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,829 IT Pros & Developers. It's quick & easy.

Adding ID to button at run time inside while loop

P: 29
hi all,
can anybody solve my probelm in asp.net using c#.

i am creating button inside while loop at runtime in html page.i just want to give different ID for different button inside while loop.how can i do that. any suggestion?any id but it should be unique.
here is my code.




Expand|Select|Wrap|Line Numbers
  1. <table style="z-index: 112; left: 24px; width: 653px; position: absolute; top: 72px;height: 344px" border="1">
  2.     <%      
  3.        while (rdr.Read())
  4.              {
  5.     %>
  6.            <tr height="5">
  7.                 <td style="width: 261px; height: 6px"><% Response.Write(rdr["comment"].ToString());%></td>
  8.                   <td style="width: 261px; height: 6px"><% Response.Write(rdr["comment"].ToString());%></td>
  9.                   <td style="width: 261px; height: 6px">
  10.                   <% Response.Write(rdr["comment"].ToString());%><br />
  11.                   <asp:Button ID="button2"  runat="server" Width="153px" Height="24px" Text="Reply"></asp:Button></td>
  12.                          </tr>
  13.                          <%  
  14.               } 
  15.  
  16. %>
  17. </table>
Feb 21 '07 #1
Share this Question
Share on Google+
1 Reply


kenobewan
Expert 2.5K+
P: 4,871
Here is an article that may help:
ASP.Net Dynamic Controls (Part 1)
Feb 22 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.