c# - 页脚按钮的 Gridview colspan

我有一个目前看起来像这样的 gridview:

我想制作带有按钮的单元格,该按钮显示添加新行以跨越其上方按钮的 2 列。

我还想在其他 4 列上添加文本框,并有效地使该行成为“添加用户行”我是初学者,仍在试验中,详细的解释将非常有帮助。

这是html代码:

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="Admin.aspx.cs" Inherits="_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link href="css/admin.css" rel="stylesheet" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <header class="grid_9">פאנל מנהל</header>
    <div class="grid_9 block_head">
        טבלת משתמשים
    </div>
    <div class="block grid_9" id="user_block" runat="server">
        <asp:GridView ID="gdview" OnRowEditing="gdview_RowEditing" DataKeyNames="id" AutoGenerateColumns="False"
            CssClass="Grid" OnRowUpdating="gdview_RowUpdating" OnRowCancelingEdit="gdview_RowCancelingEdit"
            runat="server" HeaderStyle-CssClass="tableheader" OnRowDeleting="gdview_RowDeleting" OnRowCreated="RowCreated"
            ShowFooter="true">
            <Columns>
                <asp:BoundField HeaderText="מספר מזהה" DataField="id" ReadOnly></asp:BoundField>
                <asp:BoundField HeaderText="שם משתמש" DataField="username"></asp:BoundField>
                <asp:BoundField HeaderText="סיסמא" DataField="password"></asp:BoundField>
                <asp:BoundField HeaderText="אימייל" DataField="email"></asp:BoundField>

                <asp:CommandField ShowEditButton="True" CancelText="בטל" UpdateText="עדכן" EditText="ערוך"></asp:CommandField>

                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="lnkdel" runat="server" Text="מחק" CommandName="Delete"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField>
                    <FooterTemplate>
                        <asp:Button ID="ButtonAdd" runat="server" Text="Add New Row" />
                    </FooterTemplate>
                </asp:TemplateField>

            </Columns>
        </asp:GridView>
    </div>
</asp:Content>

谢谢!

最佳答案

这可能对某人有帮助。以下链接上的解决方案对我有用: https://www.codeproject.com/Answers/544063/HowplustoplusMergepluscellsplusinplusAsp-netplusGr#answer1

来自链接的片段:

gvitems.FooterRow.Cells[0].ColumnSpan = 7;
gvitems.FooterRow.Cells.RemoveAt(1);
gvitems.FooterRow.Cells.RemoveAt(2);
gvitems.FooterRow.Cells.RemoveAt(3);
gvitems.FooterRow.Cells.RemoveAt(4);
gvitems.FooterRow.Cells.RemoveAt(5);
gvitems.FooterRow.Cells.RemoveAt(6);

https://stackoverflow.com/questions/16774638/

相关文章:

amazon-s3 - S3 如何在上传时分配时间戳?

c - 在 C 中实现 hmac sha1

version-control - P4 货架 : What is actually saved?

javascript - 类型错误:无法设置未定义的属性 'onkeydown'

perl - utf8 "\xFF"未映射到 tokenizer.perl 第 44 行

php - xdebug.remote_enable 的 ini_set 不起作用

erlang - 如何使用 PEM key 文件在 Erlang 中通过 SSH 连接

usb - 通过 USB 线的模拟信号

regex - 正则表达式 : How to find dashes between words

syntax - 初学者的 Entity Framework 语法