469,076 Members | 1,993 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,076 developers. It's quick & easy.

Adding ID to button at run time inside while loop

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.               } 
  16. %>
  17. </table>
Feb 21 '07 #1
1 1444
4,871 Expert 4TB
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.

By using this site, you agree to our Privacy Policy and Terms of Use.