locked
gridView footer invisible RRS feed

  • Question

  • User-381059448 posted

    this is my code 

    <Columns >
    <asp:TemplateField HeaderText="name">
    <ItemTemplate>
    <asp:Label Text='<%# Eval("name") %>' runat="server"/>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox ID="txtname" Text='<%# Eval("name") %>' runat="server"/>
    </EditItemTemplate>
    <FooterTemplate>
    <asp:TextBox ID="txtnamefooter" runat="server"/>
    </FooterTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="gender">
    <ItemTemplate>
    <asp:Label Text='<%# Eval("gender") %>' runat="server"/>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox ID="txtgender" Text='<%# Eval("gender") %>' runat="server"/>
    </EditItemTemplate>
    <FooterTemplate>
    <asp:TextBox ID="txtgenderfooter" runat="server" />
    </FooterTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="city">
    <ItemTemplate>
    <asp:Label Text='<%# Eval("city") %>' runat="server"/>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox ID="txtcity" Text='<%# Eval("city") %>' runat="server"/>
    </EditItemTemplate>
    <FooterTemplate>
    <asp:TextBox ID="txtcityfooter" runat="server"/>
    </FooterTemplate>
    </asp:TemplateField>
    <asp:TemplateField>
    <ItemTemplate>
    <asp:ImageButton ImageUrl="../_layouts/15/images/button img/edit.png" runat="server" CommandName="edit" ToolTip="edit" Width="20px" Height="20px" />
    <asp:ImageButton ImageUrl="../_layouts/15/images/button img/delete.png" runat="server" CommandName="delete" ToolTip="delete" Width="20px" Height="20px" />
    </ItemTemplate>
    <EditItemTemplate>
    <asp:ImageButton ImageUrl="../_layouts/15/images/button img/save.png" runat="server" CommandName="Update" ToolTip="Update" Width="20px" Height="20px" />
    <asp:ImageButton ImageUrl="../_layouts/15/images/button img/cancel.jpg" runat="server" CommandName="Cancel" ToolTip="cancel" Width="20px" Height="20px" />
    </EditItemTemplate>
    <FooterTemplate>
    <asp:ImageButton ImageUrl="../_layouts/15/images/button img/add new.jpg" runat="server" CommandName="addnew" ToolTip="addnew" Width="20px" Height="20px" />
    </FooterTemplate>
    </asp:TemplateField>
    </Columns>

    and this is my function 

    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
    GridView1.FooterRow.Visible = false;
    GridView1.EditIndex = e.NewEditIndex;
    populategridwiew();

    }

    but nothing change 

    help me please

    Friday, May 4, 2018 12:49 PM

Answers

  • User283571144 posted

    Hi ahmedshpt,

    but nothing change 

    According to your description, I suggest you could modify the GridView1.ShowFooter attribute in the code behind.

    Then it will work well,

    More  details, you could refer to below codes:

            <div>
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" ShowFooter="true"  DataKeyNames="Id" AutoGenerateEditButton="true" OnRowEditing="GridView1_RowEditing" DataSourceID="SqlDataSource1">
                    <Columns>
                        <asp:TemplateField HeaderText="Id" SortExpression="Id">
                            <EditItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Eval("Id") %>'></asp:Label>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("Id") %>'></asp:Label>
                            </ItemTemplate>
                            <FooterTemplate>
                                <asp:TextBox ID="txtgenderfooter" runat="server" />
                            </FooterTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Email" SortExpression="Email">
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Email") %>'></asp:TextBox>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("Email") %>'></asp:Label>
                            </ItemTemplate>
                            <FooterTemplate>
                                <asp:TextBox ID="txtgenderfooter1" runat="server" />
                            </FooterTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="PasswordHash" SortExpression="PasswordHash">
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("PasswordHash") %>'></asp:TextBox>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label3" runat="server" Text='<%# Bind("PasswordHash") %>'></asp:Label>
                            </ItemTemplate>
                            <FooterTemplate>
                                <asp:TextBox ID="txtgenderfooter2" runat="server" />
                            </FooterTemplate>
                        </asp:TemplateField> 
                    </Columns>
                </asp:GridView>
                <br />
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:aspnet-MVCApplication-20180424014300ConnectionString %>" SelectCommand="SELECT [Id], [Email], [PasswordHash] FROM [AspNetUsers]">
                </asp:SqlDataSource>
            </div>

    Code-behind:

            protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
            {
                GridView1.ShowFooter = false;
                GridView1.EditIndex = e.NewEditIndex;
             }

    Result:

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 8, 2018 9:07 AM

All replies

  • User283571144 posted

    Hi ahmedshpt,

    but nothing change 

    According to your description, I suggest you could modify the GridView1.ShowFooter attribute in the code behind.

    Then it will work well,

    More  details, you could refer to below codes:

            <div>
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" ShowFooter="true"  DataKeyNames="Id" AutoGenerateEditButton="true" OnRowEditing="GridView1_RowEditing" DataSourceID="SqlDataSource1">
                    <Columns>
                        <asp:TemplateField HeaderText="Id" SortExpression="Id">
                            <EditItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Eval("Id") %>'></asp:Label>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("Id") %>'></asp:Label>
                            </ItemTemplate>
                            <FooterTemplate>
                                <asp:TextBox ID="txtgenderfooter" runat="server" />
                            </FooterTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Email" SortExpression="Email">
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Email") %>'></asp:TextBox>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("Email") %>'></asp:Label>
                            </ItemTemplate>
                            <FooterTemplate>
                                <asp:TextBox ID="txtgenderfooter1" runat="server" />
                            </FooterTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="PasswordHash" SortExpression="PasswordHash">
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("PasswordHash") %>'></asp:TextBox>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label3" runat="server" Text='<%# Bind("PasswordHash") %>'></asp:Label>
                            </ItemTemplate>
                            <FooterTemplate>
                                <asp:TextBox ID="txtgenderfooter2" runat="server" />
                            </FooterTemplate>
                        </asp:TemplateField> 
                    </Columns>
                </asp:GridView>
                <br />
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:aspnet-MVCApplication-20180424014300ConnectionString %>" SelectCommand="SELECT [Id], [Email], [PasswordHash] FROM [AspNetUsers]">
                </asp:SqlDataSource>
            </div>

    Code-behind:

            protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
            {
                GridView1.ShowFooter = false;
                GridView1.EditIndex = e.NewEditIndex;
             }

    Result:

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 8, 2018 9:07 AM
  • User-381059448 posted

    thanks a lot 

    Wednesday, May 9, 2018 10:03 AM
  • User-381059448 posted

    thanks a lot it's work

    Wednesday, May 9, 2018 10:03 AM