Vijay Rajan

Vijay Rajan

  • NA
  • 5
  • 0

DataGrid Paging Problem

Oct 6 2006 1:20 PM

Hi ,


I have datagrid with 9 records.I have 3 buttons named as ,view all ,Active,Deactive.

Here my database columns are country,company,logo,status.

If i click view all the records can be viewed pagewise without any error. It is working fine.

The other 2 buttons namely:

Button Active-status is 1
Button DeActive-staus is 0

I have set pagesize= 5 , that is i have 5 records(1,2,3,4,5) in the first page,4 records(6,7,8,9) in second page.

In the first page i have 3 active records (1,3,5), and two deactive records(2,4)
if i click active in the first page only 3 active(1,3,5) should be displayed and if i click deactive only two deactive records (2,4) should be displayed. Instead  all the active records(including active records in second page) are  also displaying in that page and same problem in deactive also.

Similarly,

In the second page i have two actve records (7,9), and two deactive records(6,8)
if i click active in the second  page only 2 active(7,9) should be displayed and if i click deactive only two deactive records (6,8) should be displayed. Instead  all the active records(including active records in first page) are  also displaying in that page and same problem in deactive also.

My question is i have to display only the active records in the first page.I have set overall pagesize as 5 in my datagrid. How can i set to display only the 3 active records and two deactive records in the first page and same for second page .

I have given the code for Active & Deactive below

ACTIVE BUTTON: (status 1)
Try
           strConnString = objCsLgateway.GetConnectionString()
           conn = objCsDataBase.GetDbConnection(strConnString)
           Dim adap As New SqlDataAdapter("select DISTINCT  logo_code,company_name,country_name,category,picture_path  from tblLogos where status=1 ", conn)
           Dim ds As New DataSet
           adap.Fill(ds, "tblLogos")
           DataGrid1.CurrentPageIndex = 0
           DataGrid1.DataSource = ds
           DataGrid1.DataBind()
       Catch errEx As Exception
           Response.Write(errEx.Message)

       End Try

DEACTIVE BUTTON (status 0)
Try
           strConnString = objCsLgateway.GetConnectionString()
           conn = objCsDataBase.GetDbConnection(strConnString)
           Dim adap As New SqlDataAdapter("select DISTINCT  logo_code,company_name,country_name,category,picture_path  from tblLogos where status=0 ", conn)
           Dim ds As New DataSet
           adap.Fill(ds, "tblLogos")
           DataGrid1.CurrentPageIndex = 0
           DataGrid1.DataSource = ds
           DataGrid1.DataBind()
       Catch errEx As Exception
           Response.Write(errEx.Message)

       End Try

plz provide me with proper solution and the corrected code.

Regards,
Vijay


Answers (1)