我正在试图弄清楚如何在我的网格视图中添加一个按钮,当单击时,会形成一个下拉菜单,其中包含可点击的选项并将触发某种事件。
[以下相关图片可能有助于概念化按钮的位置]
问题是,在添加行时或以任何方式出现时都不会显示。
这是我的代码:
<asp:GridView runat="server" ID="grdvwDepositTransaction"
AutoGenerateColumns="false" DataKeyNames="Status"
OnRowCommand="grdvwDepositTransaction_RowCommand" OnRowDataBound="grd_RowDataBound"
CssClass="grid">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<ul id="actionMenuHomeScreenPanel" style="display: none; margin-top: -6px; text-align: left; " onmouseover="javascript: showMenu(); return false;" onmouseout="javascript: hideMenu(); return false;" class="ui-menu">
<li><a href="#" onclick="window.close();">Cancel</a></li>
<li>
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="btnValidateTotals_Click" Text="Validate Transactions" width="100px"></asp:LinkButton>
</li>
</ul>
</ItemTemplate>
</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.taxID" HeaderText="Tax ID" 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>
<span style="font-weight: bold; text-anchor:middle;">No Transactions have been entered</span>
</EmptyDataTemplate>
</asp:GridView>
答案 0 :(得分:0)
使用TemplateField。看看这个例子
<asp:TemplateField HeaderText="Administração">
<EditItemTemplate>
<asp:DropDownList ID="ddlAdministracao" runat="server" SelectedValue='<%# Bind("Administracao") %>' Width="90px">
<asp:ListItem Value="True" Text="Ativo" />
<asp:ListItem Value="False" Text="Bloqueado" />
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Image ID="imgAdministracao" runat="server" ImageUrl='<%# (Eval("Administracao").Equals(true) ? "Image/OK.png" : (Eval("Administracao").Equals(false) ? "Image/no.png" : "~/Image/blank.gif"))%>' />
</ItemTemplate>
</asp:TemplateField>