读书人

ASP.NET 的传值?CommandArgument Co

发布时间: 2012-10-25 10:58:57 作者: rapoo

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();//重新绑定数据库  } 

读书人网 >asp.net

热点推荐