472,131 Members | 1,323 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,131 software developers and data experts.

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 1566
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 Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.