[英]How to assign dynamic id to button in asp.net c#
I have created html table and getting dynamic data in table. 我已经创建了html表并在表中获取动态数据。 But on each button I am calling function, My server side should understand this button.
但是在我调用函数的每个按钮上,我的服务器端都应该理解此按钮。 so I need to set dynamic id or name to button.
所以我需要将动态ID或名称设置为button。 Below is my code.
下面是我的代码。 I want to give unique id to submit button.
我想给唯一的ID提交按钮。
<table cellspacing='0'> <!-- cellspacing='0' is important, must stay -->
<!-- Table Header -->
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Subject</th>
<th>Action</th>
</tr>
<!-- Table Header -->
<!-- Table Body -->
<%for (int i = 0; i < row_count; i++) { %>
<tr id="h<%=i%>"><td><%=list[0][i]%></td>
<td><%=list[1][i]%></td>
<td><%=list[2][i]%></td>
<td><%=list[3][i]%></td>
<td><%=list[4][i]%></td>
<td></td>
<td><button type="submit" id="Submit" class="submit" runat="server" onserverclick="button_Click" > Approve</button>
</td>
</tr>
<%} %>
<!-- Table Body -->
</table>
I tried to assign id as below but did't worked. 我尝试按以下方式分配ID,但没有成功。
<td><button type="submit" id="Submit<%=i%>" class="submit" runat="server" onserverclick="button_Click" > Approve</button>
</td>
You can take a look to : Dictionnary collection 您可以看一下: Dictionnary collection
https://msdn.microsoft.com/fr-fr/library/xfhwa508(v=vs.110).aspx https://msdn.microsoft.com/fr-fr/library/xfhwa508(v=vs.110).aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.