Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# itamar82 11/28/2008 12:28 PM
Hi, I'm working on a module that will provide polls for site visitors.

I'm having trouble doing databinding of a list of choices to a repeater control. Each choice has a linkbutton to "vote" for it. However, none of the data that I set in CommandArgument reaches the Click event of the linkbutton.

for example, this is the ItemDataBound event handler and linkbutton click eventhandler code for the repeater
        void rptChoices_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            PollChoice choice = e.Item.DataItem as PollChoice;           

            Literal litVotPercentage = e.Item.FindControl("litVotePercentage") as Literal;
            if (litVotPercentage != null)
            {
                if (_activePoll.TotalVotes == 0)
                {
                    litVotPercentage.Text = "0";
                }
                else
                {
                    litVotPercentage.Text = (((double)choice.Votes / _activePoll.TotalVotes) * 100).ToString();
                }
            }

            LinkButton lbtVote = e.Item.FindControl("lbtVote") as LinkButton;
            if (lbtVote != null)
            {
                lbtVote.Visible = !_activePoll.IsClosed && !HasVoted();
                lbtVote.Click += new EventHandler(lbtVote_Click);
                lbtVote.CommandArgument = choice.Id.ToString();
            }           
            
        }

        void lbtVote_Click(object sender, EventArgs e)
        {
            LinkButton lbtVote = sender as LinkButton;

            if (lbtVote == null)
                return;
                        
            for (int i = 0; i < _activePoll.Choices.Count; i++)
            {
                if (_activePoll.Choices[i].Id.ToString().Equals(lbtVote.CommandArgument))
                {
                    _activePoll.Choices[i].Votes++;
                    _module.SavePoll(_activePoll);
                    break;
                }
            }

            
        }

The commandArgument that the linkbutton has is null or String.Empty...

Has anyone encountered something like this in cuyahoga? What are the recommended solutions?

Furthermore, as soon as I finish this module, I'd like to contribute it. Please send me information as to how I can do that.
# itamar82 11/29/2008 9:14 AM (edited 11/29/2008 9:27 AM)
Ok, here is the release.

Feel free to use it or play around with it.

Features:
- Unlimited polls per section.
- Max 10 choices per poll. (Ran into problems making it dynamic so figured to just hard code it at 10) (Any choice without a value will not be displayed to User)
- Only one poll can be viewed at one time.
- Poll can be closed. (Viewed but closed to voting)
- Poll voting is tracked by IP and date. (accessed through section Edit link)
- Poll vote tracking by (IP, Cookies, or None) [in Section properties]

This is my first OSS contribution. I'd appreciate any feedback on things I did wrong/right in the module.
# martijnb 11/29/2008 1:38 PM
Thanks a lot!
# bart_s 12/2/2008 7:34 AM
I can not download attachment
Why?
# martijnb 12/2/2008 11:55 AM
Downloading attachments is fixed. Please try again.
# markfind 12/4/2008 5:46 PM
Interesting module.

What the differences between two attachments?

There is a Wrong mapping on PollVoteInfo for field VoteDate.

I would have an excel export for poll votes.

Thanks!

Marco
# itamar82 12/5/2008 7:21 AM
Hey Marco,

The forum doesn't accept uploads over a certain size and the whole project compressed is over the limit so I split it into two.

Sorry for the mapping error. I'll fix that and commit it to SVN. Can I commit with anonymous privileges?

Good idea for the export. I'll add that when I get a chance.
# goolz 12/6/2008 8:04 AM
Hi itamar82

It's very useful module, to reducing project size you can delete 'bin' folder.

# itamar82 12/7/2008 8:05 PM (edited 12/30/2008 11:06 PM)
Fixed the mapping issue. Here is the module in 1 file following goolz advice.


Furthermore, made some new modifications:

- Changed user interface to something more intuitive using radio buttons.
- Added 3d bar for each choice which represents the percentage of votes.
- Added setting for viewing total amount of votes after vote submission.
- Removed votetracking type (None)
# juanwoang 2/6/2009 6:34 PM
Thanks itamar much! I need this module now!
# juanwoang 2/7/2009 9:45 AM
When adding project into solutions, error message appears contains this: E:\Microsoft.CShap.targets was not found at line 155 of xxx.csproj file

After comment that line, i can add project, but error found when build: "Build" does not exist in the project.
# itamar82 2/10/2009 9:43 AM
I'm not really sure what that means. Anyone else?

Here is a relevant article i found about it tho:

http://stackoverflow.com/questions/5694/the-imported-project-cmicrosoftcsharptargets-was-not-found
# aliozgur 2/13/2009 3:02 PM
I think the authors Visual Studio setup has some CTP's like WPF, Linq or any other but you do not have these CTP's installed. Although you do not need these features VS inserts these lines automatically. That was a case when I installed Linq, created a project and then tried opening the project in a VS setup not having the Linq installed. You can solve the problem by creating a new project and adding source files manually.