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 8452859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:36:45+00:00 2026-06-10T11:36:45+00:00

I have a gridview that when more than 10 items are in the view,

  • 0

I have a gridview that when more than 10 items are in the view, a new page is added, pretty straightforward…Anyway, when a user is on the second page and clicks delete on that record, the item from the first page in that row is deleted. Example: page 1 had 10 items and in the first row is say a part number 1234 and on the second page the first row has part number 7890. If the user clicks delete for the 7890 record, the 1234 record is deleted from the first row, or which ever corresponding row they select to remove.

Here’s the code:

protected void griditems_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        griditems.PageIndex = e.NewPageIndex;
        BindData();
    }

EDIT Sorry everyone…here is the delete command:

 protected void griditems_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            DataTable dt = (DataTable)Session["table"];
            if (dt.Rows.Count > 0)
            {
                dt.Rows.RemoveAt(e.RowIndex);
                griditems.DataSource = dt;
                BindData();
            }
        }
        catch
        {
            //error message
        }
    }

In the aspx:

<asp:GridView ID="griditems" runat="server" onrowdeleting="griditems_RowDeleting" onrowediting="griditems_RowEditing" onrowupdating="griditems_RowUpdating"
                  AllowPaging="True" PageSize="10" onpageindexchanging="griditems_PageIndexChanging" Onrowcancelingedit="griditems_RowCancelingEdit" 
                  Caption="Order Details" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" onrowdatabound="griditems_RowDataBound" >            
        <EditRowStyle BackColor="#FF9900" BorderStyle="Double"/> 
        <RowStyle HorizontalAlign="Center"/>
</asp:GridView>
  • 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-10T11:36:46+00:00Added an answer on June 10, 2026 at 11:36 am

    You should show your griditems_RowDeleting implementation as well, but even without it I can assume that you just need to take the index of the row and add to it the page number times the amount of records in each page.

    Console.WriteLine(e.RowIndex); // 7
    Console.WriteLine(griditems.PageIndex); // 3
    
    // Assuming you have 10 records per page, you can safely say...
    var realIndexOfRecord = e.RowIndex + griditems.PageIndex * 10; // 37
    

    After your edit:

    protected void griditems_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            DataTable dt = (DataTable)Session["table"];
            if (dt.Rows.Count > 0)
            {
                // Replace `10` with the appropriate variable
                dt.Rows.RemoveAt(e.RowIndex + griditems.PageIndex * 10);
                griditems.DataSource = dt;
                BindData();
            }
        }
        catch
        {
            //error message
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a gridview that displays items details, I added two template fields one
I'm pretty new to this. I have an ASP gridview control so that in
I have a gridview that contains user info and one of the columns is
Is it possible to loop through a gridview with more than one page, the
I have a GridView with 4 images per row, and normally has more than
I have a gridview that i want to print its header on every page
I have a page that displays a gridview of products. Inside this table is
In my child user control I have a gridview with an OnRowCommand eventhandler that
I want to check that a textbox doesnt have more than one decimal point
I have a gridview that needs to be exported to Excel. I have managed

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.