0

这个我的客户我重视Eval("UserId")并试图在服务器上获取它

  <input type="button" id="Promouter" runat="server"  
        value='<%# Eval("UserId") %>' 
        onserverclick="Promoter_Onclick"> <%# Eval("FirstName") %> </input>

这台服务器

protected void Promoter_Onclick(object sender, EventArgs e)
{
    InfinityNightDataContext data = new InfinityNightDataContext();
    lvInvaited.DataSource = data.PartyPpls.Where(dbPartyPpls => dbPartyPpls.PartyId == 1 && dbPartyPpls.PromoterId == sender.value);
    lvInvaited.DataBind();
    lvInvaited.Visible = true;

}

我可以看到我需要的发件人的值,但我从发件人那里得到它我知道发件人.value 不工作我怎样才能从发件人那里得到这个值

4

1 回答 1

5

您可能必须将其转换为 HtmlInputButton。

protected void Promoter_Onclick(object sender, EventArgs e)
{
    HtmlInputButton button = (HtmlInputButton)sender;
    int value = int.Parse(button.Value.ToString()); // or int, whatever it'll be.

    InfinityNightDataContext data = new InfinityNightDataContext();
    lvInvaited.DataSource = data.PartyPpls.Where(dbPartyPpls => dbPartyPpls.PartyId == 1 && dbPartyPpls.PromoterId == value);
    lvInvaited.DataBind();
    lvInvaited.Visible = true;

}
于 2013-05-16T11:24:03.597 回答