我有一个 Gridview,我想向添加的每一行添加一个“操作”按钮,单击该按钮将允许我编辑或删除一行。
在我的图片中,它看起来像一个下拉列表。我更喜欢一个按钮,但下拉列表将作为最后的手段。
这是我到目前为止所尝试的:
<asp:GridView runat="server" ID="grdvwDepositTransaction"
AutoGenerateColumns="false" DataKeyNames="Status"
OnRowCommand="grdvwDepositTransaction_RowCommand" ShowHeaderWhenEmpty="true" ShowFooter="true" OnRowDataBound="grd_RowDataBound"
CssClass="grid" width="750">
<HeaderStyle CssClass="HeaderTemplate" />
<FooterStyle CssClass="FooterTemplate" />
<Columns>
<asp:TemplateField >
<ItemTemplate>
<input onclick="javascript: showMenu(); return false;" onmouseout="javascript: hideMenu(); return false;" type="button" class="savebutton" value="Actions" id="actionMenuRowSomething" />
<ul id="actionMenuRow" style="display: none; margin-top: -6px; text-align: left; padding: 0px; margin-right: 0px; " onmouseover="javascript: showMenu(); return false;" onmouseout="javascript: hideMenu(); return false;" class="ui-menu">
<li><a href="#" onclick="ShowHomeScreen();">something</a></li>
<li>
<asp:LinkButton ID="something" runat="server" Text="View Updates" style="width:100px;">works</asp:LinkButton>
</li>
</ul>
</ItemTemplate>
<EditItemTemplate>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="DepositEntry.cardNumber" HeaderText="Card Number" ItemStyle-CssClass="mediumColumn columnCenter" />
<asp:BoundField DataField="DepositEntry.accountNumber" HeaderText="Account Number" ItemStyle-CssClass="mediumColumn columnCenter" />
<asp:BoundField DataField="DepositEntry.firstName" HeaderText="Customer Name" ItemStyle-CssClass="mediumColumn columnCenter" />
<asp:BoundField DataField="DepositEntry.transactionDateTime" HeaderText="Transaction Date/Time" ItemStyle-CssClass="mediumColumn columnCenter" />
<asp:BoundField DataField="DepositEntry.cashAmount" HeaderText="Cash Amount" ItemStyle-CssClass="mediumColumn columnCenter" />
<asp:BoundField DataField="DepositEntry.depositAmount" HeaderText="Envelope Deposit Amount" ItemStyle-CssClass="mediumColumn columnCenter" />
</Columns>
<EmptyDataTemplate>
<br />
<br /><br />
<span style="font-weight: bold; text-anchor:middle;">No Transactions have been entered</span>
</EmptyDataTemplate>
</asp:GridView>