Repeater事件OnItemCommand取得行內(nèi)控件的方法
更新時間:2014年01月15日 15:24:58 作者:
這篇文章主要介紹了Repeater事件OnItemCommand取得行內(nèi)控件的方法,有需要的朋友可以參考一下
記錄一下,主要是這句:
TextBox txtNum = e.Item.FindControl("txtNum") as TextBox;
Repeater真是太強了,太靈活。除了Repeater別的都不用。
復制代碼 代碼如下:
<table>
<asp:Repeater ID="rptList" runat="server"OnItemCommand="rptList_ItemCommand">
<ItemTemplate>
<tr>
<td><asp:TextBox ID="txtNum" runat="server" Text='<%#Eval("ProNum")%>'></asp:TextBox></td>
<td><asp:Button ID="btnUpdate" runat="server" Text="更新"CommandName="update" CommandArgument='<%#Eval("PID") %>' /></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
復制代碼 代碼如下:
protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
{
switch (e.CommandName)
{
case "update":
string arg = e.CommandArgument.ToString();//取得參數(shù)
//找到激發(fā)事件的行內(nèi)控件,這個很有用,能將更多需要的參數(shù)值傳遞過來。
TextBox txtNum = e.Item.FindControl("txtNum") as TextBox;
//下面執(zhí)行業(yè)務邏輯
string jsStr = "<script>alert('刪除成功!" + txtNum.Text + "')</script>";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", jsStr,false);
break;
}
Bind();
}
您可能感興趣的文章:
- Repeater控件與PagedDataSource結合實現(xiàn)分頁功能
- Repeater控件實現(xiàn)編輯、更新、刪除等操作示例代碼
- Repeater怎么實現(xiàn)多行間隔顯示分隔符
- Repeater中嵌套Repeater的示例介紹
- repeater做刪除前彈窗詢問實例
- 給Repeater控件里添加序號的5種才常見方法介紹
- asp.net Repeater 數(shù)據(jù)綁定的具體實現(xiàn)(圖文詳解)
- Repeater控件綁定的三種方式
- ASP.NET筆記之 Repeater的使用
- asp.net Repeater分頁實例(PageDataSource的使用)
- Repeater里switch的使用方法
- Repeater中添加按鈕實現(xiàn)點擊按鈕獲取某一行數(shù)據(jù)的方法
相關文章
asp.net中調(diào)用Office來制作3D統(tǒng)計圖的實例代碼
這篇文章介紹了asp.net中調(diào)用Office來制作3D統(tǒng)計圖的實例代碼,有需要的朋友可以參考一下2013-11-11
DataView.RowFilter的使用(包括in,like等SQL中的操作符)
這篇blog轉自C# examples,對DataView.RowFilter做了詳細介紹,能像SQL中使用in,like等操作符一樣進行過濾查詢,并附有實例,使用方便。2011-07-07
如何在ASP.NET Core中給上傳圖片功能添加水印實例代碼
這篇文章主要給大家介紹了關于如何在ASP.NET Core中給上傳圖片功能添加水印的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧2019-02-02

