首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

ASP.NET 的传值?CommandArgument CommandArgument 的应用

2012-10-25 
ASP.NET 的传值?CommandArgumentCommandArgument的运用图片按钮:asp:ImageButton IDbtnEdit runatse

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

热点排行