Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Let's say in javascript function I get a new gridview page index. How to simulate GridView1_PageIndexChanging event if it's possible at all?
Posted
Updated 23-Mar-18 18:43pm
Comments
DamithSL 29-Nov-14 22:36pm    
why you need to do it from javascript? this server side event will fire automatically if you set it correctly
esb77 30-Nov-14 11:26am    
Just to add a bit more of convenience - I'd like to show a user what each page starts with. When you have a big list with many pages and looking for a particular record it takes some guessing what page # to click.

That is a Server Side event and GridView is a server side control. If you want to fire that from client side, then use some HTML Grid Control or simply a Table and simulate the Grid first.

You can also go for jQGrid, which suits your requirement better. You can handle every grid event from client side if you use that.
 
Share this answer
 
 
Share this answer
 
Comments
esb77 30-Nov-14 12:55pm    
strange I tried that before unsuccessfully. This time it worked fine. I even made some changes
$('#<%=btn.ClientID%>').click(); instead of
__doPostBack('btn_Click', '');
It takes me directly to the click event without having that extra code on Page Load.
Thanks
Here after two times click only im getting next page in gridview, please give me a solution


<asp:GridView ID="gridDisplay" CssClass="gridDisplay" runat="server" CellPadding="3" AutoGenerateColumns="False"
EmptyDataText="--No Data Available--" BackColor="White" onrowcommand="griddocument_RowCommand"
BorderColor="#CCCCCC" BorderStyle="None" PageSize="10" BorderWidth="1px" Width="100%"
style="margin-right: 0px;font-size:12px;" onrowdatabound="gridDisplay_RowDataBound" AllowPaging="True" OnPageIndexChanging="gridDisplay_PageIndexChanging" >



protected void gridDisplay_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gridDisplay.PageIndex = e.NewPageIndex;
binddata();

}
 
Share this answer
 
Comments
CHill60 24-Mar-18 12:45pm    
If you have a question then use the red "Ask a question" link at the top of the page. Do not post questions or comments as answers

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900