Click here to Skip to main content
15,907,395 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Friends,

I have 10 records in my table. Now I have to bind the data into gridview, whenever click on the entire the gridviewrow record displaying another page like Details.aspx. In Detail.aspx page I have two link buttons like Previous, Next. Whenever click on next I want display next gridview row data, in the same whenever click on previous I need display previous gridview row data. If previous & next records are not available the next & previous buttons will be disable.

Thanks in advance.
Posted
Comments
Rajesh waran 27-Oct-14 8:45am    
try to get that 10 id value from your gridview datasource,in (next or prev)button click event,use Response.Redirect() function ,here u can provide Details.aspx with id values . Then use query string on Details.aspx page to get all id values,here you can bind your new grid with id values.

Hello ,
Refer : GridView-Custom-Paging
thanks
 
Share this answer
 
Comments
Member 10021658 27-Oct-14 3:36am    
Dear Animesh,

Thanks for your reply. But in my requirement the Details.aspx output is like,
Id:100, Name: Raju, College: Govt Engg College, City: Bangalore.

Now whenever click on previous I need display 99 Id records in same Details.aspx page, in the same next button I need to display 101 record.
Animesh Datta 27-Oct-14 3:54am    
Have you gone through the article ? It is clearly written that
PAGE_SIZE is the total number of records displayed on each page . Here you must set it to 1 . I suggest you to read the article carefully and then implement according to your requirement.
Member 10021658 27-Oct-14 4:41am    
Thank you Animesh. It's great help to me.
Animesh Datta 27-Oct-14 5:21am    
Welcome dear .Please accept the answer if the problem is solved.
ASP.NET
<asp:gridview id="GridView1" runat="server" backcolor="White" showfooter="false" xmlns:asp="#unknown">
        AutoGenerateColumns="False" PageSize="5"
        OnPageIndexChanging="GridView1_PageIndexChanging" AllowPaging="True" OnRowCreated="GridView1_RowCreated"   PagerSettings-Position="TopAndBottom" PagerStyle-HorizontalAlign="Left" PagerStyle-Wrap="true" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" Width="100%" GridLines="Both">
<alternatingrowstyle backcolor="AliceBlue" />
<pagerstyle horizontalalign="Center" backcolor="White"></pagerstyle>
<pagersettings position="TopAndBottom" firstpagetext="First" lastpagetext="Last">
        Mode="NumericFirstLast" ></pagersettings>
    <rowstyle forecolor="#000066" horizontalalign="Center" />
<columns></columns>
</asp:gridview>



C#
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        BindGrid();
    }


public void BindGrid()
{

sqlcommand cmd=new sqlcommand("select * from tblname",sqlconnection);
    SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds=new DataSet();
da.Fill(ds);
GridView1.DataSource=ds;
GridView1.DataBind();

}
 
Share this answer
 
v2
Comments
Member 10021658 27-Oct-14 7:37am    
Dear Kumaran, Thanks your reply. According your answer is suitable for how to set paging in gridview. But my requirement is I have to pass the gridview row data values from BindGrid.aspx to Details.aspx page. Here I need to working with previous & next buttons not entire records only respective Id values (one record).

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