zoukankan      html  css  js  c++  java
  • DataList中TextBox的OnTextChange事件


     <DataList ID="dlblogs" Height="450" Width="100%" PageSize="18" CellPadding="0" EnableViewState="true"
                CellSpacing
    ="0" runat="server" OnItemDataBound="BindDataItem" OnUpdateCommand="UpdateName" 
                RepeatColumns
    ="3" CssClass="grbk_allarticlebg">
        
    <ItemStyle HorizontalAlign="left" VerticalAlign="top" />
        
    <ItemTemplate>
            
    <td width="200" height="136" align="center" valign="top">
                
    <table width="100" border="0" cellspacing="0" cellpadding="0">
                    
    <tr>
                        
    <td height="35" align="center" class="blackfont">
                            
    <asp:Label ID="lblId" runat="server" Visible="false" Text='<%# Eval("Id") %>'></asp:Label>
                            
    <asp:TextBox ID="txtName" CssClass="input-none"  runat="server" Text='<%# Eval("Name") %>'></asp:TextBox>
                            
    <asp:LinkButton Text="Update" CommandName="Update" runat="server" ID="btn" Visible="false" />
                        
    </td>
                    
    </tr>
                
    </table>
            
    </td>
        
    </ItemTemplate>
    </DataList>

    cs代码


    #region ItemDataBound
        
    protected void   BindDataItem(object   src,DataListItemEventArgs   e)
        {
            
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                TextBox box 
    = e.Item.FindControl("txtName"as TextBox;
                LinkButton btn 
    = e.Item.FindControl("btn"as LinkButton;
                
    if (box != null && btn != null)
                {
                    box.Attributes.Add(
    "onchange"this.GetPostBackEventReference(btn));
                }
            }   
        }
        
    #endregion

    #region Update
        
    protected void UpdateName(object src, DataListCommandEventArgs e)
        {
            TextBox box 
    = e.Item.FindControl("txtName"as TextBox;
            
    if (box != null)
            {
                
    //在此做相应的处理事件
            }
        }
        
    #endregion
  • 相关阅读:
    Test_StringBuilder
    什么是朋友
    Uncharted4-Resource-Extract
    在使用 .NET Remoting 技术开发跨进程通信时Remoting找不到请求的服务--解决方法
    SourceTree 拉取github资源包时报错:fatal: unable to access 'https://github.com/xxx.git/': OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 --解决办法
    .net core3.1 文件导出报错The type initializer for 'Gdip' threw an exception 的解决方法
    .net core3.1文件下载之MimeTypeMapHelper
    .net core3.1 webapi项目部署在centos7中,通过supervisor来做进程守护遇到backoff Exited too quickly (process log may have details)的错误--并提供解决方法
    jenkins安装在ubuntu的解决方法-运维系列
    supervisord.conf配置文件详情
  • 原文地址:https://www.cnblogs.com/wantingqiang/p/1421885.html
Copyright © 2011-2022 走看看