首页 > 代码库 > Repeater 中 OnItemCommand 用法
Repeater 中 OnItemCommand 用法
1 <table> 2 <asp:Repeater ID="rptList" runat="server"OnItemCommand="rptList_ItemCommand"> 3 <ItemTemplate> 4 <tr> 5 <td><asp:TextBox ID="txtNum" runat="server" Text=‘<%#Eval("ProNum")%>‘></asp:TextBox></td> 6 <td><asp:Button ID="btnUpdate" runat="server" Text="更新"CommandName="update" CommandArgument=‘<%#Eval("PID") %>‘ /></td> 7 </tr> 8 </ItemTemplate> 9 </asp:Repeater> 10 </table>
1 protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e) 2 { 3 switch (e.CommandName) 4 { 5 case "update": 6 string arg = e.CommandArgument.ToString();//取得参数 7 //找到激发事件的行内控件,这个很有用,能将更多需要的参数值传递过来。 8 TextBox txtNum = e.Item.FindControl("txtNum") as TextBox; 9 10 //下面执行业务逻辑 11 string jsStr = "<script>alert(‘删除成功!" + txtNum.Text + "‘)</script>"; 12 Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", jsStr,false); 13 break; 14 } 15 16 }
控件还是比较好理解~~
Repeater 中 OnItemCommand 用法
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。