开发者

How do I pass parameters to an asp.net function from an asp.net control inside an itemtemplate

开发者 https://www.devze.com 2023-04-10 00:57 出处:网络
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

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

精彩评论

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