0

我有一个 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>
4

2 回答 2

0

尝试以下操作:

 <asp:TemplateField HeaderText="">                         
                        <EditItemTemplate>
                            <asp:ImageButton ID="ibtnUpdate" runat="server" CommandName="Update" CausesValidation="true" ImageUrl="~/Content/Images/h.ico"  />
                            <asp:ImageButton ID="ibtnCancel" runat="server" CommandName="Cancel" CausesValidation="false" ImageUrl="~/Content/Images/j.ico"  />
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:ImageButton ID="ibtnEdit" runat="server" CommandName="Edit" CausesValidation="false" ImageUrl="~/Content/Images/k.ico"  />
                            <asp:ImageButton ID="ibtnDelete" runat="server" CommandName="Delete" CausesValidation="false" ImageUrl="~/Content/Images/l.ico"  />
                        </ItemTemplate>                          
                    </asp:TemplateField>

您可以在其中以您喜欢的方式参考图像。

于 2014-10-20T19:50:30.060 回答
0

有什么理由必须仅限于一列吗?然后你可以使用:

AutoGenerateDeleteButton="True"
AutoGenerateEditButton="True"

...并且连接比确定选择了哪个下拉项目等容易得多。

于 2014-10-20T19:55:37.463 回答