开发者

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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜