Solved

PageIndexChanged event is not getting fired in .net 2.0

Posted on 2008-10-21
13
746 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 C P
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +2
13 Comments
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22773485
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
ID: 22773510
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
ID: 22773697
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22773705
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
ID: 22773710
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
 
LVL 1

Expert Comment

by:ashishkaithi
ID: 22773748
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 C P
ID: 22773921
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 C P
ID: 22773928
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 C P
ID: 22773951
Can someone help me out in this?

Thanks in advance
0
 
LVL 1

Expert Comment

by:ashishkaithi
ID: 22774390
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
ID: 22776680
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

732 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