cyberdaemon 1 Light Poster

Good day,

I am havinf trouble with the pageindexchanging in my gridview

here is my code;

my PAgeIndexChanging code

 protected void gvPatientInformation_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GetPatientInfor(_patientInformation);
            gvPatientInformation.PageIndex = e.NewPageIndex;

        }

my Method Code

 private void GetPatientInfor(PatientInformation _patientInformation)
        {
            gvPatientInformation.DataSource = PatientInformationBL.listPatientIformation(_patientInformation);
            gvPatientInformation.DataBind();
        }

My BLL code

 public static DataTable listPatientIformation(PatientInformation _patientInformation)
        {
            return DataAccess.getDatatable(_patientInformation.createSpDbCommand("sp_LIST_PATIENTRECORDINFORMATION", DBTRANS.LIST));
        }

and lastly my query code

ALTER PROCEDURE [dbo].[sp_LIST_PATIENTRECORDINFORMATION]
    -- Add the parameters for the stored procedure here
    --@HOSPITAL_CODE INT
    @FIRSTNAME NVARCHAR(50)
    ,@MIDDLENAME NVARCHAR(50)
    ,@LASTNAME NVARCHAR(50)
    ,@GENDER NVARCHAR(6)
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    SET @FIRSTNAME      =       REPLACE(@FIRSTNAME, '','%')
    SET @LASTNAME       =       REPLACE(@LASTNAME, '','%')
    SET @MIDDLENAME     =       REPLACE(@MIDDLENAME,'', '%')



    SELECT 
        PATIENT_ID
        ,MRN
        ,FIRSTNAME
        ,MIDDLENAME
        ,LASTNAME
        ,GENDER
        ,BIRTHDATE 
        ,MARITAL_STATUS

        FROM Patient_Information 

        WHERE 
        (FIRSTNAME LIKE  @FIRSTNAME OR @FIRSTNAME IS NULL)
        AND (MIDDLENAME LIKE @MIDDLENAME OR @MIDDLENAME IS NULL)
        AND (LASTNAME LIKE @LASTNAME OR @LASTNAME IS NULL)

END

my problem is that every time i click on the page index in my gridview my grid loaded all the record on the database. but apprenly on the first load the grid view will load the what i want to see..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.