How do I pass parameters to an asp.net function from an asp.net control inside an itemtemplate
I have a vote button in a repeater and I want to use it by giving 开发者_运维技巧the post id which is in the same itemtemplate in a repeater/datalist. I can't pass the value I get from Eval() to the codebehind function because it takes 2 arguments which are sender and eventargs
use OnCommand
instead of OnClick
:
<asp:Button ID="btnVote" runat="server" Text="Vote" OnCommand="btnVote_Command" CommandArgument='<%#Eval("Column1")%>' />
In the code-behind:
protected void btnVote_Command(object sender, CommandEventArgs e)
{
object column1 = e.CommandArgument;
}
精彩评论