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

  • Home
  • SEARCH
  • 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 8748543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:32:35+00:00 2026-06-13T12:32:35+00:00

For some reason a gridview is not being refreshed automatically after a row has

  • 0

For some reason a gridview is not being refreshed automatically after a row has been deleted. When I’m debbuging the code it reaches UserAccessGrid_RowDeleted method but nothing happens on the page. Here’s my code.

    <ajax:UpdatePanel ID="UserAccessGridUpdatePanel" runat="server" RenderMode="Inline" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:GridView ID="UserAccessGrid" runat="server" DataKeyNames="UserID" AutoGenerateColumns="False" OnRowDeleting="UserAccessGrid_RowDeleting" OnRowDeleted="UserAccessGrid_RowDeleted"
            CellPadding="3" Width="100%">
            <RowStyle CssClass="GridRow" />
            <AlternatingRowStyle CssClass="GridAltRow" />
            <HeaderStyle HorizontalAlign="Left" />
            <Columns>     
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" OnClientClick="return confirm('Are you sure you want to delete this user?');"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Employee Name">
                    <ItemTemplate>
                        <a href="AddUser.aspx?uid=<%# QueryStringEncryption.Encrypt( DataBinder.Eval(Container.DataItem, "UserID").ToString() )%>">
                            <%#DataBinder.Eval(Container.DataItem, "EmployeeName") %>
                        </a>
                    </ItemTemplate>                        
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Email">
                    <ItemTemplate>
                        <%#DataBinder.Eval(Container.DataItem, "EmailAddress")%>
                    </ItemTemplate>                        
                </asp:TemplateField>
                <asp:CheckBoxField 
                    DataField="IsCSEAdmin" 
                    HeaderText="CSE Administrator" 
                    ReadOnly="True" 
                    ItemStyle-HorizontalAlign="Center" >
                <ItemStyle HorizontalAlign="Center" />
                </asp:CheckBoxField>
                <asp:CheckBoxField 
                    DataField="IsAdmin" 
                    HeaderText="Country Administrator" 
                    ReadOnly="True" 
                    ItemStyle-HorizontalAlign="Center" >
                <ItemStyle HorizontalAlign="Center" />
                </asp:CheckBoxField>
            </Columns>
        </asp:GridView>
    </ContentTemplate>
    <Triggers>
        <ajax:AsyncPostBackTrigger ControlID="UserAccessGrid" />
    </Triggers>
</ajax:UpdatePanel>

Code behind:

    protected void Page_Load(object sender, EventArgs e)
{
    if (!(Master.user.IsAdmin || Master.user.IsCSEAdmin))
        Response.Redirect("Unauthorized.aspx");

    //UserAccessDS.SelectParameters["UserID"].DefaultValue = Master.user.UserID;
    if (!Page.IsPostBack)
    {
        UserAccessGridBind();
    }
}

protected void UserAccessGrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
    int UserID = (int)UserAccessGrid.DataKeys[e.RowIndex].Value;
    if (Convert.ToInt32(Master.user.UserID) == UserID)
    {
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Alert", "alert('Delete action permitted on that user!');", true);
    }
    else
    {
        OleDbCommand command = new OleDbCommand("dbo.usp_DeleteUserbyUserID", Master.connection);
        command.Connection.Open();

        try
        {
            command.CommandType = CommandType.StoredProcedure;
            OleDbParameter param = command.Parameters.Add("@UserID", OleDbType.Integer);
            param.Value = UserID;

            command.ExecuteNonQuery();

            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Information", "alert('Delete complete.');", true);
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Alert", "alert('An error occured : " + ex.Message + "');", true);
        }
        finally
        {
            command.Connection.Close();
        }
    }
}

protected void UserAccessGrid_RowDeleted(object sender, GridViewDeletedEventArgs e)
{
    UserAccessGridUpdatePanel.Update();
}

private void UserAccessGridBind()
{
    int UserID = Convert.ToInt32(Master.user.UserID);

    OleDbDataAdapter adapter = new OleDbDataAdapter();
    OleDbCommand command = new OleDbCommand("dbo.usp_GetAccessListByUserID", Master.connection);

    command.CommandType = CommandType.StoredProcedure;
    command.Parameters.AddWithValue("UserID", UserID);

    adapter.SelectCommand = command;

    DataSet UserAccess = new DataSet();
    adapter.Fill(UserAccess);

    UserAccessGrid.DataSource = UserAccess;
    UserAccessGrid.DataBind();
}
  • 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-13T12:32:36+00:00Added an answer on June 13, 2026 at 12:32 pm

    You need to bind the grid again after delete. As you binded earlier.

    Call UserAccessGridBind() method to refresh the grid after deleting record.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to remove a row from my gridview manually, because for some reason,
For some reason, this line of code is returning undefined for $(this).attr(href) $(a).attr(href, javascript:page('
For some reason there's a variable called d that is defined immediately after I
For some reason beyond me my html page is not finding my stylesheet. I'm
I am trying to add a new row into a gridview but for some
I having issues exporting a GridView to Excel for some reason. I have two
I have a gridview that I databind dynamically in my codebehind. For some reason,
For some reason i am getting an object refrence not set to an instance
I am trying to create a gridview in extjs using json. For some reason
For some reason i can not format the text of my date in a

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.