Solved

PageIndexChanged event is not getting fired in .net 2.0

Posted on 2008-10-21
13
736 Views
Last Modified: 2012-05-05
Hi Experts,
I have a major issue in ASP.net2.0. I had written a code for PageIndexChanged event in .net .1.1. That worked fine. But when I ported the same code to .net 2.0, the event is not getting fired at all. Can anyone help me on this
0
Comment
Question by:mukunda_cp
  • 3
  • 3
  • 2
  • +2
13 Comments
 
LVL 26

Expert Comment

by:Anurag Thakur
Comment Utility
can you please share your code so that we can have a look and give you a solution
just telling us that something is not working without any code snipped does not make it easy for us to even suggest anything
0
 
LVL 5

Expert Comment

by:varungd
Comment Utility
U do one thing  select the grid take the properties and click on event and double click on
'PageIndexChanged'  then write the code.
0
 
LVL 2

Expert Comment

by:spiderexpa
Comment Utility
Add the following attribute for gridview in .aspx file:----->

OnSelectedIndexChanged="grdView1_SelectedIndexChanged"

Now, use the following code:----->

protected void grdView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grdView1.PageIndex = e.NewPageIndex;
        BindGrid(); // Write this function for binding gridView.
    }
0
 
LVL 26

Expert Comment

by:Anurag Thakur
Comment Utility
the code has been migrated from 1.1 framework to 2.0 framework
how can the gridview be there -- the author will be using the datagrid as after migration the control is not changed for backward compatibality and migrated code.

Please share your code so that we can have a look at it and try to help you better
0
 
LVL 2

Expert Comment

by:spiderexpa
Comment Utility
Correction on previous answer:
==================

Add the following attribute for gridview in .aspx file:

OnPageIndexChanging="grdItems_PageIndexChanging"

Now, use the following code:----->

protected void grdView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grdView1.PageIndex = e.NewPageIndex;
        BindGrid(); // Write this function for binding gridView.
    }
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Expert Comment

by:ashishkaithi
Comment Utility
Hi,

 GridView in .aspx file:



I m attaching code in code snippet  ::==>

REMEMBER TO WRITE IN PageIndexChanging


protected void ashGrid_PageIndexChanging(object Sender,GridViewPageEventArgs e)

    {

        ashGrid.PageIndex = e.NewPageIndex;

        BindGrid(); // Write this function for binding gridView.

    }

Open in new window

0
 

Author Comment

by:mukunda_cp
Comment Utility
I have added the code snippet for the same.

I have also added OnPageIndexChanged event in .aspx page. I dont have a GridView. Instead I have a DataGrid. I have directly ported from .net1.1 to .net 2.0
<asp:DataGrid id="MyGrid"    OnPageIndexChanged="dgrid_PageIndexChanged">

protected void dgrid_PageIndexChanged(object source, DataGridPageChangedEventArgs e)

        {

            try

            {

                dtgJournal.CurrentPageIndex = e.NewPageIndex;                
 

		//To Store the journal grid visible columns in to the hashtable for sorting purpose.

                colHeaderMap = new Hashtable();

		int idx = 0;

		foreach (DataGridColumn col in dtgJournal.Columns)

		{

			colHeaderMap[col.SortExpression] = idx++;

		}

                

//		Getting Visible Columns and Binding the Journal Data to the Grid.

                BindUIToDataSet(emailsDataSet);//Binds the DS

            }//try

            catch (Exception)

            {

            }//catch

        //}

        }

Open in new window

0
 

Author Comment

by:mukunda_cp
Comment Utility
The code snippet
protected void dgrid_PageIndexChanged(object source, DataGridPageChangedEventArgs e)

        {

            try

            {

                dgrid.CurrentPageIndex = e.NewPageIndex;                
 

		//To Store the journal grid visible columns in to the hashtable for sorting purpose.

                colHeaderMap = new Hashtable();

		int idx = 0;

		foreach (DataGridColumn col in dtgJournal.Columns)

		{

			colHeaderMap[col.SortExpression] = idx++;

		}

                

//		Getting Visible Columns and Binding the Journal Data to the Grid.

                BindUIToDataSet(emailsDataSet);//Binds the DS

            }//try

            catch (Exception)

            {

            }//catch

        //}

        }

Open in new window

0
 

Author Comment

by:mukunda_cp
Comment Utility
Can someone help me out in this?

Thanks in advance
0
 
LVL 1

Expert Comment

by:ashishkaithi
Comment Utility
hi mukund u better use GridView for the same.
It has enhanced features from datagrid of older version in .net
0
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 500 total points
Comment Utility
try to register the event manually

// Manually register the event-handling method for the PageIndexChanged  
// event of the DataGrid control.
dgrid.PageIndexChanged += new DataGridPageChangedEventHandler(this.dgrid_PageIndexChanged);

the following link might be useful
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datagrid.pageindexchanged.aspx
http://authors.aspalliance.com/JimRoss/Articles/DatagridDiet.aspx
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now