0

I am now trying to use gridview to create a web application for users to delete some rows from database. However, whenever I refresh the whole page, strange things happen as selectedIndexChanged was called. Is there any way that I can avoid this method being called whenever I refresh the table or is can I use javascript to detect this event? If not, can I generate a yes no dialog for that event like javascript? I am quite new to asp.net and my questions may be quite stupid. Please help!

3
  • you could move it all to JS or simply forums.asp.net/t/… Commented Jun 16, 2015 at 1:26
  • Can you post the code of your markup page? also, javascript can handle different events, but what event you're trying to handle? Commented Jun 16, 2015 at 2:04
  • Actually I am trying to handle selectedIndexChanged Commented Jun 16, 2015 at 2:14

2 Answers 2

1

I think you need to decide if you want to use JS or ASP to handle events on the page.

If you want to use JS, then disable server processing in your ASP tags and handle all the interactions with JS in your page and only process at the server on page submit. ASP can generate the grid for you on page load, but then let JS handle the client side interactions.

If you want to use ASP, then set your grid to process on the server (runat="server") and forget about JS.

Sign up to request clarification or add additional context in comments.

Comments

0

Well seems I found out the solution. Actually C# also provides yes no dialog. Seems I could use it to manually stop that event but it seems that I cannot avoid selectedIndexChanged being called when refreshing the page. Thank you every one for your help.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.