简体   繁体   中英

How to add 5 Textboxes and 1 button to GridView in footer ASP.NET?

Like in title? have no idea how to do it

I wrote something like this:

<Columns>
     <asp:TemplateField>
          <FooterTemplate>
              <asp:TextBox ID="TextBox1" runat="server" />
              <asp:TextBox ID="TextBox2" runat="server" />
              <asp:TextBox ID="TextBox3" runat="server" />
              <asp:TextBox ID="TextBox4" runat="server" />
              <asp:TextBox ID="TextBox5" runat="server" />
              <asp:Button ID="Button1" runat="server" />
          </FooterTemplate>
     </asp:TemplateField>

     <asp:CommandField ShowEditButton="True" />
          <asp:BoundField DataField="id" HeaderText="ID" Visible="False" />
          <asp:BoundField DataField="Name" HeaderText="Name" />
          <asp:BoundField DataField="LastName" HeaderText="LastName" />
          <asp:BoundField DataField="something" HeaderText="something" />
          <asp:BoundField DataField="country" HeaderText="country" />
          <asp:CommandField ShowDeleteButton="True" />
</Columns>

but it gives me extra column i want to add this textbox in the column that already exists.

将GridView的ShowFooter设置为true,并为要显示页脚的任何列定义FooterTemplate,然后将5个文本框和1个按钮添加到此模板部分。

<asp:GridView ID="GridView1" runat="server" ShowFooter="true">
    <Columns>
        <asp:TemplateField>
            <FooterTemplate>
                <asp:TextBox ID="TextBox1" runat="server" />
                <asp:TextBox ID="TextBox2" runat="server" />
                <asp:TextBox ID="TextBox3" runat="server" />
                <asp:TextBox ID="TextBox4" runat="server" />
                <asp:TextBox ID="TextBox5" runat="server" />
                <asp:Button ID="Button1" runat="server" />
            </FooterTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

That is how.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM