Click here to Skip to main content
16,022,538 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

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.
 
Share this answer
 
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
 
Share this answer
 

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