我有一个html表,其中包含来自sql的数据。每一行都有一个“给予”按钮。我需要当按下时,“代码”单元格的值被转移到C#代码中。"code“列具有唯一的值,可以用作id。
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<table class="table table-striped table-hover">
<thead class="thead-light">
<tr>
<th></th>
<th scope="col">name</th>
<th scope="col">sur</th>
<th scope="col">code</th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tbody id="myTable">
<tr>
<th><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">give</button> </th>
<td><%# Eval("name")%></td>
<td><%# Eval("sur")%></td>
<td><%# Eval("code")%></td>
</tr>
</tbody>
</itemtemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>发布于 2020-12-29 10:53:15
如果我真的明白你的问题,
您可以使用commandArgument,但是首先,如果您没有任何guid或Id,您可以在sql或frontSide中创建它,那么我认为sql查询中的newID()是完美的,然后将其放在隐藏值或frontSide中的CommandArgument中。然后C#端您可以处理Repeater1_ItemCommand中的所有进程并从
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "guid")
{
Int32 id = Convert.ToInt32(e.CommandArgument);
}
}https://stackoverflow.com/questions/65490264
复制相似问题