ASP.NET 的传值?CommandArgument CommandArgument 的运用
图片按钮:<asp:ImageButton ID="btnEdit" runat="server" ImageUrl="~/Images/edit.gif" CausesValidation="false" CommandArgument='<%#Eval("StuSeat") %>'/> protected void rptStuInfo_ItemCommand(object source, RepeaterCommandEventArgs e) 这个e也是空值? {
string empid = e.CommandArgument.ToString();
stuInfo stu = ddc.stuInfo.First(s => s.StuNo ==empid);
ddc.stuInfo.DeleteOnSubmit(stu);
ddc.SubmitChanges();
this.rptStuInfo.DataBind();//重新绑定数据库
}
哪里错了 求教~
------解决方案--------------------
<asp:ImageButton ID="btnEdit" runat="server" ImageUrl="~/Images/edit.gif" CausesValidation="false" CommandArgument='<%#Eval("StuSeat") %>' OnCommand="rptStuInfo_ItemCommand"/>
C# code
protected void rptStuInfo_ItemCommand(object source, [color=#FF0000]CommandEventArgs e[/color]) {
string empid = e.CommandArgument.ToString();
stuInfo stu = ddc.stuInfo.First(s => s.StuNo ==empid);
ddc.stuInfo.DeleteOnSubmit(stu);
ddc.SubmitChanges();
this.rptStuInfo.DataBind();//重新绑定数据库
}