How to implement a voting system?

I need to implement functionality similar to SO voting. I tried to find some existing questions on this topic and noticed that most people are fixated on how to vote up and down. I walked past this. my problem is how to handle after the vote has been supported. this is what i have done so far.

  • Voting up, down and rating are displayed for each answer.
  • The number of votes is changed when the user presses up or down, and the image is updated accordingly.
  • Save the information in db. who voted, voting time, type of voting, userIP, ansID, etc.

Now questions.

  • I use gridview to display information. as I show previously voted answers, as voted to load the next page. I have information in db, but I want to do this without affecting performance. I could do this in the itemDatabound event, but it doesn't look like a nice way to handle this. I am wondering if there is a better way to handle this situation.
  • Switch votes: when the user switches the vote, what happens behind the scenes. is the previous entry deleted or not? I say it should be deleted, but confirmation.
  • Is gridview a good way to implement such functionality or not?
+6
language-agnostic
source share
1 answer

For

1) If you use gridview, you almost have to go this route. But we need more details about what you are trying to do.

2) When you post and then post the same answer / question, it should be checked and deleted. Remember that you are only allowed 1 vote per question or answer so that your database table is written so that there is a unique row for the user ID, QuestionID (given that the question is unique). Therefore, you should not even let it insert duplicate rows into the table.

3) stackoverflow is an application like mvc, you use web forms, so you can use gridview or listview. They probably just iterate over the answers and generate html (like this MVC).

+2
source share

All Articles