如何获得下一个&以前在ASP.Net中使用GridView控件的记录? [英] How to get next & previous records using GridView Control in ASP.Net?

查看:47
本文介绍了如何获得下一个&以前在ASP.Net中使用GridView控件的记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我的桌子上有10条记录。现在,我必须将数据绑定到gridview,每当单击整个gridviewrow记录时,显示另一个页面,如Details.aspx。在Detail.aspx页面中,我有两个链接按钮,如Previous,Next。每当点击下一个我希望显示下一个gridview行数据时,无论何时点击前一个我都需要显示前一个gridview行数据。如果前一个和下一个记录不可用,则下一个和前一个按钮将被禁用。



提前感谢。

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.

推荐答案

您好,

参考: GridView-Custom-Paging

谢谢
Hello ,
Refer : GridView-Custom-Paging
thanks


<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>










    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();

}


这篇关于如何获得下一个&amp;以前在ASP.Net中使用GridView控件的记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆