Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7850063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:43:50+00:00 2026-06-02T18:43:50+00:00

I’ve got a gridview inside an update panel. In the gridview I have an

  • 0

I’ve got a gridview inside an update panel.
In the gridview I have an image button.
The button is used to delete a row.

In the rowCommand event of the grid view I do something like this:

 protected void gvLineItems_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            GridViewRow row = (GridViewRow)((Control)e.CommandSource).NamingContainer;

            switch (e.CommandName)
            {
                case "Delete":
                    Label l = null;
                    l = (Label)row.FindControl("lblLineItemID");

                    if(l!=null)
                    {
                        long lID;
                        lID = Convert.ToInt64(l.Text);
                        BL.DeleteLineItem(Convert.ToInt64(hlID.Text), lID);
                        BindGrid(Session["SortExpression"].ToString(), Convert.ToInt32(rbSortGrid.SelectedValue));
                    }
                    break;
            }
        }

I debug this and I see the row deleted in the database (data is deleted correctly). But the gridview still shows the “deleted” row even after bind grid. Bind grid is simple it looks like this:

protected void BindGrid(string sortExpression, int sortDirection)
        {
            DataSet ds

            ds = BL.GetLineItemGridData(Convert.ToInt64(hlID.Text), sortExpression, sortDirection);

            gvLineItems.DataSource = ds.Tables[0];
            gvLineItems.DataBind();
            gvLineItems.Visible = true;
        }

The dataset is returning the correct rows (without the deleted row) but when I look at the webpage it still shows the row that was deleted.

Edit

Someone asked for the HTML of the gridview, here it is:

<asp:UpdatePanel ID="myPanel" runat="server" UpdateMode="Always">
             <ContentTemplate>
                <asp:GridView GridLines="Horizontal" CellPadding="4" Font-Size="Small" 
                     DataKeyNames="ID" Width="100%" AlternatingRowStyle-BackColor="#e5f1fa" 
                     BackColor="#E8E8E8" HeaderStyle-ForeColor="White" 
                     HeaderStyle-BackColor="#1367AD" ID="gvLineItems" runat="server" 
                     AllowSorting="True" AutoGenerateColumns="False" ShowFooter="True" 
                     onrowcommand="gvLineItems_RowCommand" >
                    <Columns>
                    <asp:TemplateField>
                       <ItemStyle Width="1px" />
                       <ItemTemplate>
                            <asp:Label Width=".05px" ID="lblLineItemID" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.ID") %>' style="display:none"></asp:Label>
                       </ItemTemplate>
                       <ControlStyle Width="0px" />
                       <HeaderStyle Width="0px" />
                     </asp:TemplateField> 
                    <asp:TemplateField>
                       <HeaderTemplate>
                          <asp:CheckBox ToolTip="Select / Deselect all rows?" ID="HeaderLevelCheckBox" onclick="toggleSelection(this);" runat="server" />
                       </HeaderTemplate>
                       <ItemTemplate>
                          <asp:CheckBox ID="chkSelector" ToolTip="Select row?" runat="server" onclick="ChangeRowColor(this)" />
                       </ItemTemplate>
                       <ItemStyle HorizontalAlign="Center" />
                       <HeaderStyle HorizontalAlign="Center" />
                    </asp:TemplateField>
                    <asp:TemplateField>
                       <ItemTemplate>
                         <asp:ImageButton ID="ibAddLineItem" runat="server" ImageUrl="images/InsertRow.gif" CommandName="Insert" ToolTip="Insert new line item."/>
                       </ItemTemplate>
                    </asp:TemplateField>  
                    <asp:TemplateField>
                       <ItemTemplate>
                         <asp:ImageButton ID="ibDeleteLineItem" runat="server" ImageUrl="images/DeleteRow.gif" CommandName="Delete" ToolTip="Delete line item."/>
                       </ItemTemplate>
                    </asp:TemplateField>                          
                    <asp:TemplateField HeaderText="Item #" SortExpression="LineItemNumber">
                         <ItemTemplate>
                             <asp:Label runat="server" ID="lblItemNumber" Visible="True" Text='<%# DataBinder.Eval(Container, "DataItem.LineItemNumber") %>' />
                         </ItemTemplate>
                         <ItemStyle Width="10%" HorizontalAlign="Center" />
                         <HeaderStyle HorizontalAlign="Center" Width="10%" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Quantity" SortExpression="LineItemQuantity">
                          <ItemTemplate>
                              <asp:TextBox Font-Names="Arial" ToolTip="Enter item quantity." ID="txtLineItemQuantity" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.LineItemQuantity") %>' /> 
                              </ItemTemplate>
                              <ItemStyle Width="4%" HorizontalAlign="Center" />
                              <HeaderStyle HorizontalAlign="Center" Width="4%" />
                     </asp:TemplateField>
                    <asp:TemplateField HeaderText="Description" SortExpression="LineItemDescription">
                          <ItemTemplate>
                              <asp:TextBox Columns="15" Width="300px" Font-Names="Arial" ToolTip="Enter item description." ID="txtLineItemDescription" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.LineItemDescription") %>' /> 
                              </ItemTemplate>
                              <ItemStyle Width="15%" HorizontalAlign="Left" />
                              <HeaderStyle HorizontalAlign="Left" />
                     </asp:TemplateField>
                     <asp:TemplateField HeaderText="Added By" SortExpression="AddedBy">
                         <ItemTemplate>
                             <asp:Label runat="server" ID="lblAddedBy" Visible="True" Text='<%# DataBinder.Eval(Container, "DataItem.AddedBy") %>' />
                         </ItemTemplate>
                         <ItemStyle Width="10%" HorizontalAlign="Center" />
                         <HeaderStyle HorizontalAlign="Center" Width="10%" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Added On" SortExpression="AddedOn">
                         <ItemTemplate>
                             <asp:Label runat="server" ID="lblAddedOn" Visible="True" Text='<%# DataBinder.Eval(Container, "DataItem.AddedOn") %>' />
                         </ItemTemplate>
                         <ItemStyle Width="10%" HorizontalAlign="Center" />
                         <HeaderStyle HorizontalAlign="Center" Width="10%" />
                    </asp:TemplateField>
                    </Columns>
                </asp:GridView>
             </ContentTemplate>
             <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnAddLineItem" />
                <asp:AsyncPostBackTrigger ControlID="rbSortGrid" />
             </Triggers>
         </asp:UpdatePanel>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:43:53+00:00Added an answer on June 2, 2026 at 6:43 pm

    Err I got it I just added this:

     protected void gvLineItems_RowDeleting(object sender, GridViewDeleteEventArgs e)
            {
                DataSet ds = null;
                gvLineItems.DataSource = null;
                ds = BL.GetLineItemGridData(Convert.ToInt64(hlID.Text), Session["SortExpression"].ToString(), Convert.ToInt32(rbSortGrid.SelectedValue));
    
                gvLineItems.DataSource = ds.Tables[0];
                gvLineItems.DataBind();
                gvLineItems.Visible = true;
            }
    

    And removed the call to BindGrid from this:

     protected void gvLineItems_RowCommand(object sender, GridViewCommandEventArgs e)
            {
                GridViewRow row = (GridViewRow)((Control)e.CommandSource).NamingContainer;
    
                switch (e.CommandName)
                {
                    case "Delete":
                        Label l = null;
                        l = (Label)row.FindControl("lblLineItemID");
    
                        if(l!=null)
                        {
                            long lID;
                            lID = Convert.ToInt64(l.Text);
                            BL.DeleteLineItem(Convert.ToInt64(hlID.Text), lID);
                            //BindGrid(Session["SortExpression"].ToString(), Convert.ToInt32(rbSortGrid.SelectedValue));
                        }
                        break;
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.