7

I am required to implement a functionality similar to SO voting. I tried to look up some existing questions around this topic and noticed that most people are stuck with how to vote up and down. i am past that. my problem is related to how to handle after a vote has been upvoted. here is what i have done till now.

  1. Vote up, Down and Score displayed for each answer.
  2. Vote count changed when user clicks up or down and the image is updated accordingly.
  3. Save the information in db like. who voted, time of vote, type of vote, userIP, ansID, etc.

Now the questions.

  1. I am using a gridview to display information. how do i show the previously voted answers as voted on next page load. I have the information in db but i want to do this without affecting performance. I could do it in itemDatabound event but it doesnt look like a pretty way to handle it. i wonder if there is a better way to handle such situation
  2. Toggle Votes : When a user toggles a vote, what happens behind the scenes. is the previous upvoted record deleted or not? i say it should be deleted but want a confirmation.
  3. Is gridview a good way to implement such functionality or not?
Andreas Bonini
  • 44,018
  • 30
  • 122
  • 156
  • 2
    You will want to rephrase this question, removing references to SO. Otherwise, it will be transferred to Meta, where you probably won't get a useful answer, –  Mar 04 '10 at 16:34
  • 4
    @John, Aside from question #2, this isn't a meta question. It's asking how to implement a specific feature using StackOverflow as an example. – Brandon Mar 04 '10 at 16:34
  • If you want to know about SO specifically, ask over at meta.stackoverflow.com. If you want ideas for implementing your own voting system, I'd change the title and specify the platform you're working on. – Seth Petry-Johnson Mar 04 '10 at 16:35
  • Whether or not to delete the toggled vote is a matter of how important it is to you to keep this information. – Decent Dabbler Mar 04 '10 at 16:36
  • Neil is right, you wont get a useful answer there. It's odd that people want to close a valid question just because it references SO. – JonH Mar 04 '10 at 16:38
  • This question is not related to SO. I am required to program a similar functionality and i have a .Net problem. –  Mar 04 '10 at 16:40
  • 5
    [reopened] This is a programming-question. The fact that it uses Stack Overflow as an example is irrelevant. This **does not** belong on Meta. – Sampson Mar 04 '10 at 17:15
  • 1
    @Sarah: This is a design question, and as such not clearly a programming question. The aspects of it that are programming questions seem to relate to using .NET, and so I'd suggest that you edit your question to remove the "language-agnostic" tag and substitute one or more platform tags. – David Thornley Mar 04 '10 at 18:01
  • @Jonathan Sampson - I guess there is a lot of misleading direction. Personally I found it rather strange that a question was closed just because it referenced stack overflow. Someone added a comment (which looks to be deleted) that stated something to the effect of "Jeff Atwood states you cannot mention stack overflow within your post, so rename it". Then they went on to say that was a general rule. 2-3 questions from Sarah were closed just today just because she used SO in the title. What gives ? – JonH Mar 04 '10 at 18:17
  • @JonH: Looks like one question was migrated to MSO because she asked how SO does something, and in that case I have to agree with the migrators. This is a question about replicating part of SO, so that's not grounds for closing, but I don't think the misleading "language-agnostic" tag is helping here. – David Thornley Mar 04 '10 at 18:42
  • Thanks guys for the feedback. i think it has been pointed out correctly that i would not get an answer in meta. It was a problem not about SO and i just referenced it as an example of how it is done there. thanks again everyone. –  Mar 05 '10 at 04:17
  • @JonH: The first rule of Stack Overflow is you do not mention Stack Overflow. The second rule of Stack Overflow is you do *not* mention Stack Overflow. –  Mar 05 '10 at 20:47

1 Answers1

2

For

1) If you are using a gridview you almost have to take this route. But we need more details about what you are trying to do.

2) When you upvote and then downvote that same answer / question it should be checked and deleted. Remember you are only allowed 1 vote for a question or answer so your database table should be written so that their is a unique row for a userID, a QuestionID (given that a question is unique). So you should not even allow it to insert duplicate rows in a table.

3)stackoverflow is mvc type app, you are using webforms, so you could use a gridview or a listview. They are probably just looping through the answers and generating the html (as this is MVC).

JonH
  • 32,732
  • 12
  • 87
  • 145