#
itamar82
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
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.
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.