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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:28:03+00:00 2026-06-17T09:28:03+00:00

I am having a problem in my gridview, my Gridview has a event of

  • 0

I am having a problem in my gridview, my Gridview has a event of OnPageIndexChanging,
the pagesize of my gridview is 20

once the record was reach 20 in the first page, the 21st-40th record will go to the second page, when I go to the second page, and I click the edit button in my gridview..
ex: I click the row for 21st record in gridview

the EditItemTemplate for that row is not showing, but I am not encountering a problem and my code is executing well when I am debugging it.

here is my code in “EditRow” in Gridview_RowCommand

protected void gridview_RowCommand(object sender, GridViewCommandEventArgs e)
{

        int iActiveIndex;

        switch (e.CommandName)
        {
            case "EditRow":
                iActiveIndex = Convert.ToInt32(e.CommandArgument);

                gridview.EditIndex = iActiveIndex;

                gridview.DataSource = emp.TrainingPrograms;
                gridview.DataBind();
                break;
         }
}

This is the code in Gridview_OnPageIndexChanging

protected void gridview_OnPageIndexChanging(object sender, GridViewPageEventArgs e)
{

        gridview.DataSource = emp.TrainingPrograms;
        gridview.PageIndex = e.NewPageIndex;
        gridview.DataBind();
}

Is there any possible solution with my problem?

  • 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-17T09:28:04+00:00Added an answer on June 17, 2026 at 9:28 am

    The EditIndex property of the GridView control refers to the Xth row on the current page, not the id of the row to be edited.

    The proper row can be selected by taking the modulus of the rowindex by the pagesize as thus:

    gridview.EditIndex = iActiveIndex % gridview.PageSize;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

all. I'm having a problem getting the GridView.AutoGenerateEditButton property to do anything for me.
I'm having trouble creating a Gridview that can span 2 rows for each record.
I'm having a problem and I cannot understand why. I have a GridView and
The problem I am having is in a gridview I have multiple buttons and
This solution is for an unbounded Gridview paging and having problem with the syntax
I having a problem to make HtmlEncode work properly inside a GridView in ASP.Net.
I'm having a problem passing a date value from a GridView generated HyperLinkField to
I'm having a strange problem here... I have an ASP.NET 3.5 application that has
I have a nested gridview in my page. The first one is used like
I am having a problem while trying to refresh data in a Gridview, the

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.