正在加载...

上海朗晟网络
Repeater事件OnItemCommand取得行内控件
发布时间:2013/10/2   已被4494人阅读

记录一下,主要是这句:
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="btn " runat="server" Text="更新" CommandName=" " CommandArgument= <%#Eval("PID") %> /></td>
</tr>
    
</ItemTemplate>
    
</asp:Repeater>
</table>

 

protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
{
    
switch (e.CommandName)
     {
        
case " ":
            
string arg = e.CommandArgument.ToString();//取得参数
            
//找到激发事件的行内控件,这个很有用,能将更多需要的参数值传递过来。
             TextBox txtNum = e.Item.FindControl("txtNum") as TextBox;
            
            
//下面执行业务逻辑
            string jsStr = "< >alert( 删除成功!" + txtNum.Text + " )</ >";
             Page.Client .RegisterClient Block(
this.GetType(), "alert", jsStr, false);
            
break;
     }
     Bind();
}

protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
{
    switch (e.CommandName)
     {
        case " ":
            string arg = e.CommandArgument.ToString();//取得参数
            //找到激发事件的行内控件,这个很有用,能将更多需要的参数值传递过来。
             TextBox txtNum = e.Item.FindControl("txtNum") as TextBox;
            
            //下面执行业务逻辑
            string jsStr = "< >alert( 删除成功!" + txtNum.Text + " )</ >";
             Page.Client .RegisterClient Block(this.GetType(), "alert", jsStr, false);
            break;
     }
     Bind();
} 


本文分享地址:http://m.cn7080.com/news/73.html
上海网站建设公司朗晟网络编辑,转发请注明来源及版权归属。

分享

上一篇:没有了
下一篇:朗晟网络公司新版官方网站正式上线