如何在asp.net中创建下一个和上一个移动? [英] how to create move next and previous in asp.net?

查看:85
本文介绍了如何在asp.net中创建下一个和上一个移动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在门户网站中搜索作业asp.net和gridview中列出的10jobs然后我点击第一份工作查看工作详情(viewjob.aspx)。

如何使用在viewjob中移动下一个上一个?



对于ex,我们将在gmail中看到。我们点击电子邮件,然后查看同一页面中的详细信息,我们可以看到下一封电子邮件,而无需返回收件箱。



提前Thasnks。

Hi,
in portal I search by job "asp.net" and 10jobs listed in gridview then i click first job to view the Job details(viewjob.aspx).
How to use move next previous in viewjob?

For ex we will see that in gmail. we click email then view details in that same page we can see next email without go back to inbox.

Thasnks in advance.

推荐答案

如果你的问题是关于gridview分页,那么将允许分页属性设置为true。你将自动获得next和prev按钮并在pageindexchanging事件中显示功能,或者如果你想使用外部按钮继续分页功能,那么下面给出的例子是这样的。

if ur question is regarding gridview paging then set the allowing paging property as true. u will get next and prev button automatically and wirte the functionality in "pageindexchanging event" or if u want to continue the paging functionality using outside buttons then here is the example given below.
public partial class _Default : System.Web.UI.Page
{
static SqlConnection cn = new SqlConnection("server=DEVAPP;user id=sa;password=sa123;database=test");
protected void Page_Load(object sender, EventArgs e)
{
getdata();
}
public void getdata()
{
SqlDataAdapter da = new SqlDataAdapter("select * from employee", cn);
DataSet ds = new DataSet();
da.Fill(ds, "emp");
GridView1.DataSource = ds;
GridView1.DataBind();
}
protected void prev_Click(object sender, EventArgs e)
{
if (GridView1.PageIndex > 0)
{
GridView1.PageIndex = GridView1.PageIndex - 1;
getdata();
}
}
protected void next_Click(object sender, EventArgs e)
{
GridView1.PageIndex = GridView1.PageIndex + 1;
getdata();
}
}


您必须触发查询才能返回结果以及行号列。为此使用SQL Server的Row_Number()函数。移动到所选记录的详细信息页面时,也传递行号(客户端或服务器端)。单击下一个或上一个按钮,您可以运行用于绑定gridview的相同查询,并根据您可以显示所选记录的行号。
You will have to fire a query to return the result plus a column for row number. Use Row_Number() function of SQL Server for this. When moving to the details page for the selected record, pass the row number also (client side or server side). on click of next or previous buttons, you can run the same query that you used to bind the gridview and based on the row number you can show the selected record.


这篇关于如何在asp.net中创建下一个和上一个移动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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