我正在使用转发器控件来查看数据库表数据,我想在每行旁边添加一个链接按钮以删除特定行,我该如何使用 vb.net 来做到这一点?
问问题
6022 次
1 回答
1
没什么可做的,您要显示它吗(所有行的链接按钮?如果是,请尝试以下代码)
<table cellpadding="0" cellspacing="0">
<tr valign="top" class="list_heading">
<td width="25%">
Column
</td>
<td width="25%">
Operation
</td>
<td width="19%" style="display: none;">
And/Or
</td>
<td width="25%">
Value
</td>
<td width="06%">
Remove
</td>
</tr>
<tbody>
<asp:Repeater ID="rpSearchItems" runat="server">
<ItemTemplate>
<tr>
<td style="display: none;">
</td>
<td>
<%# Eval("ColumnName") %>
</td>
<td>
<%# Eval("Operation") %>
</td>
<td style="display: none;">
<%# Eval("AndOr") %>
</td>
<td>
<%# Eval("Value") %>
</td>
<td align="center">
<asp:ImageButton ID="ibtnRemoveSearchItem" ImageUrl="~/Controls/ImagesForSearch/Remove.png"
CommandArgument=' <%# Eval("Id") %>' CssClass="RemoveUitem" ToolTip="Remove Item"
runat="server" OnClick="ibtnRemoveSearchItem_Click" />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</tbody>
<tr valign="top" class="list_bottom">
<td colspan="6">
</td>
</tr>
</table>
在代码后面的代码中,您可以这样:
Protected Sub ibtnRemoveSearchItem_Click(sender As Object, e As EventArgs)
ImageButton ibtnRemoveSearchItem = (ImageButton)sender;
Int32 Id = Convert.ToInt32(ibtnRemoveSearchItem.CommandArgument);
//Using the above two lines you can get the Coomand Argument, pass it to you delete stored proc thats all
// do your stuff here
End Sub
希望对你有帮助
更新: 如果你想有条件地添加它,那么你可以从中继器的“ OnItemDataBound ”事件中做到这一点
欲了解更多信息,请查看此
于 2013-04-22T12:45:16.283 回答