前台: <td><asp:LinkButton id="btnDelFollowUp" Text="删除" runat="server" CommandName="delete" CommandArgument='<%# Eval("ID").ToString()%>' OnClick="btnDelFollowUp_Click"></asp:LinkButton></td>
报错如标题所示,请问应该怎么改好?
后台:
protected void btnDelFollowUp_Click(object sender,RepeaterCommandEventArgs e)
{
if (e.CommandName == "delete")
{
int id = int.Parse(e.CommandArgument.ToString());
funcDel(id);
}
}
在事件把你的Click事件改成Command事件
<asp:LinkButton id="btnDelFollowUp" Text="删除" runat="server" CommandName="delete"
CommandArgument='123'
oncommand="btnDelFollowUp_Command"></asp:LinkButton>
protected void btnDelFollowUp_Command(object sender, CommandEventArgs e)
{
if (e.CommandName == "delete")
{
int id = int.Parse(e.CommandArgument.ToString());
}
}
这个问题找了一个下午也没找到,在你这里轻松获得了答案,太感谢了。