Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Reply
 
LinkBack Thread Tools Display Modes
Old 01-05-2011, 02:51 PM   #1 (permalink)
Right Off the Assembly Line
 
Join Date: Apr 2011
Location: BBSR, Orissa
Posts: 34
Default pageindex changed event in gridview


How to handle the pageindexChanged in gridview in asp.net
in the following code?

protected void Page_Load(object sender, EventArgs e)
{
ob.conn();
gridview();

}
public void gridview()
{
ob.grdv("select * from user_album where user_id='" + Session["user_id"].ToString() + "'", GridView1);


}
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
gridview();
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
gridview();
}

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
if (GridView1.EditIndex!=-1)
{
// Use the Cancel property to cancel the paging operation.
e.Cancel = true;

// Display an error message.
int newPageNumber = e.NewPageIndex + 1;
Response.Write("<script>alert('Please update the record before moving to page')</script>");
}
else
{
// Clear the error message.

}
}
protected void GridView1_PageIndexChanged(object sender, EventArgs e)
{
what to write here show that is goes to the page number clicked...
}
binay00713 is offline   Reply With Quote
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 01-05-2011, 05:22 PM   #2 (permalink)
XLr8
 
arpanmukherjee1's Avatar
 
Join Date: Sep 2008
Posts: 637
Default Re: pageindex changed event in gridview

1. how many records does ob.grdv fetch?
2. what is the no of lines of the gridview?

if paging is enabled for gridview and 1 > 2 . then you wont have to write any code for GridView1_PageIndexChanged

do i explain myself ??
__________________
Quote:
There are more things in heaven and earth, Horatio,
Than are dreamt of in your philosophy.
arpanmukherjee1 is offline   Reply With Quote
Old 01-05-2011, 06:26 PM   #3 (permalink)
Right Off the Assembly Line
 
Join Date: Apr 2011
Location: BBSR, Orissa
Posts: 34
Default Re: pageindex changed event in gridview

Quote:
Originally Posted by arpanmukherjee1 View Post
1. how many records does ob.grdv fetch?
2. what is the no of lines of the gridview?

if paging is enabled for gridview and 1 > 2 . then you wont have to write any code for GridView1_PageIndexChanged

do i explain myself ??
ob.grdv fetches 6 records and no. of lines of the gridview is 3
paging is enabled (AllowPaging=""true")
still not going to next page..
what is 1>2 ? i cant understand .please explain
binay00713 is offline   Reply With Quote
Old 01-05-2011, 08:37 PM   #4 (permalink)
XLr8
 
arpanmukherjee1's Avatar
 
Join Date: Sep 2008
Posts: 637
Default Re: pageindex changed event in gridview

^^ not to worry. you answered my question.

one more thing ::
what exactly does // Clear the error message. does??

in addition what it does, try to insert the lines that are in bold

Code:
......
......            
.....
     Response.Write("<script>alert('Please update the record before moving to page')</script>");
        }
        else
        {
            // Clear the error message.
             ......
             ......
                       
            //finally going to the next page
            GridView1.PageIndex = e.NewPageIndex;
            gridview();
        }
    }
    protected void GridView1_PageIndexChanged(object sender, EventArgs e)
    {
        //what to write here show that is goes to the page number clicked...
    }
}
does that help ???
__________________
Quote:
There are more things in heaven and earth, Horatio,
Than are dreamt of in your philosophy.
arpanmukherjee1 is offline   Reply With Quote
Old 02-05-2011, 01:09 AM   #5 (permalink)
Right Off the Assembly Line
 
Join Date: Apr 2011
Location: BBSR, Orissa
Posts: 34
Default Re: pageindex changed event in gridview

thank you ,that worked
i feel relaxed nw
thanks a lot....
binay00713 is offline   Reply With Quote
Old 02-05-2011, 01:15 AM   #6 (permalink)
XLr8
 
arpanmukherjee1's Avatar
 
Join Date: Sep 2008
Posts: 637
Default Re: pageindex changed event in gridview

^^ ur welcome.

please edit your first post and wrap the code inside
Code:
code tags
block
__________________
Quote:
There are more things in heaven and earth, Horatio,
Than are dreamt of in your philosophy.
arpanmukherjee1 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by Charan
- by Sarath
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 12:27 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2