Instructions on pages navigation by clicking bottom page numbers

When I search, my grid displays 20 records. If I have paging enabled and the page size is set to 20, clicking on the 2nd page refreshes the entire grid, showing me the 1st page again.

How can I view the last 10 records (11-20) when there are 20 total records and the page size is set to 10?

Below is the client-side code of the grid:

<div id="divApplication" runat="server">
    <asp:GridView ID="gvApplication"
        runat="server"
        AutoGenerateColumns="false"
        AllowPaging="true"
        AllowSorting="True"
        AlternatingRowStyle-CssClass="alt"
        PagerStyle-CssClass="pgr"
        OnPageIndexChanging="OnPageIndexChanging"
        CssClass="table table-bordered table-striped"
        PageSize="10" Width="50%">

        <Columns>
            <asp:TemplateField HeaderText='Application' HeaderStyle-VerticalAlign="Middle">
                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" CssClass="chkbox" />
                <ItemTemplate>
                    <asp:Label ID="lblFirstName" runat="server"
                        att='<%#DataBinder.Eval(Container.DataItem,"ID")%>' Text='<%# SetLinkCodeApplication(Convert.ToInt64(DataBinder.Eval(Container.DataItem,"ID")),DataBinder.Eval(Container.DataItem,"Application").ToString()) %>'></asp:Label>
                </ItemTemplate>
                <ItemStyle Width="3%" HorizontalAlign="left" />
            </asp:TemplateField>
        </Columns>

    </asp:GridView>
</div>

Server-side code for binding the grid:

public void fncfillApplication()
{
    try
    {
        DataSet ds = new DataSet();
        ds.ReadXml(Server.MapPath("Application.xml"));
        if (ds.Tables[0].Rows.Count != 0)
        {
            gvApplication.DataSource = ds;
            gvApplication.DataBind();
        }
    }
    catch (Exception ex)
    {
        ex.Message.ToString();
    }
}

protected void OnPageIndexChanging(object sender, GridViewPageEventArgs e)
{
    gvApplication.PageIndex = e.NewPageIndex;
    this.fncfillApplication();
}

Method for setting link code in edit mode:

public string SetLinkCodeApplication(Int64 sId, string sName)
{
    string functionReturnValue = null;
    try
    {
        functionReturnValue = "<a href=javascript:fncopenEditPopUpApplication(" + sId + ")>" + sName.Trim() + "</a>";
        //return functionReturnValue;
    }
    catch (Exception ex)
    {
        throw;
    }
    return functionReturnValue;
}

I am using XML Datasource to bind data.

Answer №1

In my opinion, it would be beneficial to utilize the following code snippet:

XDocument document = XDocument.Load(@"c:\users\administrator\documents\visual studio 2010\Projects\LINQtoXMLSelectApp\LINQtoXMLSelectApp\Employee.xml");
var query = from r in document.Descendants("Employee") where (int)r.Element("Age") > 27 select new
{
    FirstName = r.Element("FirstName").Value, Age = r.Element("Age").Value };
GridView1.DataSource = query;
GridView1.DataBind();

Answer №2

The issue you are experiencing is not occurring on my end; everything seems to be working properly. I have successfully utilized the XML file below for binding to a gridview. The code and HTML remain unchanged:

    <?xml version="1.0" encoding="utf-8" ?>  
<Customer>  
  <Customerinfo>  
    <Name>John Doe</Name>  
    <city>New York</city>  
    <Address>123 Main St, New York</Address>  
 </Customerinfo>  
  <Customerinfo>  
    <Name>Jane Smith</Name>  
    <city>Los Angeles</city>  
    <Address>456 Elm St, Los Angeles</Address>  
  </Customerinfo>  
  <Customerinfo>  
    <Name>Michael Johnson</Name>  
    <city>Chicago</city>  
    <Address>789 Oak St, Chicago</Address>  
  </Customerinfo>  
  <Customerinfo>  
    <Name>Sarah Jenkins</Name>  
    <city>Miami</city>
    <Address>101 Pine St, Miami</Address>  
  </Customerinfo>  
  // Remaining customer data truncated for brevity
</Customer>  

Answer №3

I believe this information may be beneficial to you

ds.Tables[0].Select("ID=1 AND ID2=3");

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unable to return data to HTML page

I'm utilizing EJS to pass some data to my webpage. Here's the snippet of code: app.post('/ttt', function (req,res){ res.render('index.ejs', {titles: 'CAME IN'}) }); HTML <form id="mc-form" action="http://loc ...

"Enjoy a unique browsing experience with a two-panel layout featuring a fixed right panel that appears after scrolling

I am facing difficulty in designing a layout with two panels where the left panel has relative positioning and the right panel becomes fixed only after a specific scroll point. Additionally, I need the height of the right panel to adjust when the page scro ...

Including items into an array through user input

My goal is to create a form that allows users to choose from two different "activities". The information entered will be saved along with personal details, and later displayed below each corresponding activity. Additionally, I want to give the ability to a ...

Issue with Flask-Cors in Nuxt with Flask and JWT authentication implementation

I have exhausted all the available solutions to my issue, but I still can't seem to pinpoint the problem. Despite trying every solution out there, nothing seems to be of any help. Every time I make a request, the browser blocks it due to CORS Policy ...

Update the position of a div when an element becomes visible

Currently, I have 3 titles each with a button underneath to reveal more information about the subject. To toggle the visibility of the content, I have implemented a script that shows or hides the corresponding div when the button is clicked. On smaller de ...

Display radio buttons depending on the selections made in the dropdown menu

I currently have a select box that displays another select box when the options change. Everything is working fine, but I would like to replace the second select box with radio buttons instead. Can anyone assist me with this? .sub{display:none;} <sc ...

Maintain the button's color when clicked UNTIL it is clicked again

I am facing a challenge where I need to dynamically select multiple buttons that change color upon click. Once a button is clicked, it should change color and if clicked again, revert back to its original color. Unfortunately, I cannot rely on HTML attribu ...

Upon the initial loading of the React component, I am retrieving undefined values that are being passed from the reducer

Upon the initial loading of the React component, I am encountering an issue where the values originating from the reducer are showing up as undefined. Below is a snippet of my code: const [componentState, dispatchComponentState] = useReducer( versionReduc ...

What is the best way to make a container 100% tall and display a navigation bar?

Struggling to properly render my React page This is what I have: ReactDOM.render( <React.StrictMode> <Provider store={store}> <Router /> </Provider> </React.StrictMode>, document.getEl ...

The issue arises when trying to use jQuery on multiple elements with the same class

Recently, I came across a jQuery script for my mobile menu that changes the class on click event. jQuery("#slide-out-open").click(function() { if( jQuery( this ).hasClass( "slide-out-open" ) ) { jQuery('#wrapper').css({overflow:"hidd ...

Establishing a connection to the Oracle database

Since today is my first attempt at using Oracle databases in Asp.NET, I am feeling lost and unsure about what steps to take. Here is the code I have added: Dim oOracleConn As OracleConnection = New OracleConnection() oOracleConn.ConnectionString = "Data ...

What is the best way to connect depositors with withdrawers using Node.js?

I am in need of a matching-engine microservice for my application, where I have to establish a matching system between depositors and withdrawers. To achieve this, all the details of depositors and withdrawers are stored in a redis cache. With numerous req ...

Error: Module 'electron-prebuilt' not found

I am encountering an issue with my Electron app that utilizes Nightmare.js after compiling it into an .exe file using electron-packager. Everything functions properly until I click a button that triggers Nightmare.js, at which point I receive the followi ...

Utilize OpenLayer3 to showcase Markers and Popups on your map

I am currently exploring how to show markers/popups on an osm map using openlayers3. While I have come across some examples on the ol3 webpage, I'm interested in finding more examples for coding markers/popups with javascript or jquery, similar to som ...

Can an input element be used to showcase a chosen image on the screen?

I would like to display the selected image from an input element. Can this be done with a local file, accessing the image on the client side, or do I need to upload it to a server? Here is my React code attempt: I can retrieve the correct file name from t ...

Tips for adding data to a JSON file without altering its structure

I am currently working on a file to handle data in JSON format using JSON.NET for serialization and deserialization. As a newcomer, I am facing a challenge with appending additional JSON data to the existing file content. int count = 0; EmployeeDetail e ...

The magic of handling buffers in NodeJS with JavaScript!

In my project, I am working on developing a client-server application. The goal is for the client to send a list of filenames to the server in an array format like this: let files = ["Cat.jpeg", "Moon.gif"]. To accomplish this task, I plan to utilize Buffe ...

The system encountered an issue while trying to access the 'bannable' property, as it was undefined

message.mentions.members.forEach(men => { let member = message.mentions.members.get(men) if (!member.bannable) return message.reply(not_bannable) const reason = args.slice(1).join(" "); member.ban({reason: reason ...

Display a hidden form field in Rails depending on the object's value

As a programmer learning Ruby on Rails without much knowledge of Javascript, I faced a problem with a form that creates an object called Unit. This Unit model is related to Category which in turn is related to Product. The issue was that while selecting a ...

Ways to simulate a plugin in Jest

My unit testing setup is causing issues because I am not properly mocking the imported plugin function in my code. What is the correct way to mock the logData function? The plugin intentionally returns undefined, and my goal is to ensure that I utilize co ...