用两个按钮在页面中分页 [英] paging in a page with two buttons

查看:74
本文介绍了用两个按钮在页面中分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人


我有一个asp.net页面,其中有两个按钮,每个按钮显示不同的数据,一旦用户单击其中一个按钮,按钮一个显示特定日期的数据,另一个显示特定位置的数据.按钮的数据在启用分页的情况下显示.

问题是在运行"PageIndexChanging"函数时,我需要知道单击了哪个按钮,以便可以运行特定的查询.

我怎么知道触发索引功能的按钮的ID.

谢谢

Dear all


I have a page asp.net , in which I have two buttons, each button shows different data, button one shows data for a certain chosen date, the other shows data for a certain chosen location, once the user clicks on either one of the buttons data for the clicked button is shown with paging enabled.

the problem is when running "PageIndexChanging" function, I need to know which of the buttons has been clicked so that I can run the specific query.

How can I know thw ID of the button that triggered the indexing function.

Thank you

推荐答案

您实际上不需要知道单击了哪个按钮.假设您有某种导航方法,可以从事件处理程序调用该方法,其参数显示的方向为下一个"或上一个".它可以是布尔参数(true表示Next,false表示Previous),或者更好的是,枚举类型具有值Next和Previous(以防您在服务器端执行并使用VB.NET;如果您的意思是在处理程序上客户端,它可以是JavaScript函数中的布尔参数).

现在,您的下一个"和上一个"按钮应添加略有不同的事件处理程序:下一个"应使用下一个或参数的真值调用此方法,而上一个"应使用上一个或参数的假值调用相同的方法.

就这样.

—SA
You don''t really need to know which button is clicked. Suppose you have some method of navigation you can call from the event handler with the parameter showing direction — next or previous. It could be a Boolean parameter (true means Next, false means Previous) or, better yet, enumeration type with the values Next and Previous (in case you do in on server side and use VB.NET; if you mean a handler on the client side, it could be Boolean parameter in a JavaScript function).

Now, your "Next" and "Previous" buttons should add slightly different event handler: "Next" should call this method with Next or true value of parameter, and "Previous" should call the same method with Previous or false value of the parameter.

That''s it.

—SA


您需要一个公共变量.
单击按钮一时,将变量设置为1.单击按钮二时,将变量设置为2.
然后,您可以从变量的值中知道单击了哪个按钮.
You need a public variable.
You set the variable equals 1 when the button one be clicked.You set the variable equals 2 when the button two be clicked.
Then you can know which button been clicked from the value of the variable.


这篇关于用两个按钮在页面中分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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