此我的客户端我输入了值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;
}
我可以看到我需要的发件人的价值,但我从发件人那里得到它我知道sender.value dosn不工作 如何从发件人
获取此值答案 0 :(得分: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;
}