• 获取ListView中的ImageButton


    1.前台代码:给ImageButton控件里CommandArgument属性赋值,并且在ListView上添件onitemediting事件

    <asp:ListView ID="lvwSubsidizeList" runat="server" onitemediting="lvwSubsidizeList_ItemEditing" >
      <ItemTemplate>
        <tr>
          <td height="30">
            <%# Eval("ProjectName")%>
          </td>
          <td>
                <%# DateTime.Parse(Eval("ApprovalDate").ToString()).ToString("yyyy-MM-dd")%>
             </td>
            <td align="center">
               <asp:ImageButton ID="ibtnEdit" runat="server" ImageUrl="/Images/btn_edit.png" CommandName="Edit" CommandArgument='<%# Eval("ID") %>' />
             </td>
        </tr>
      </ItemTemplate>
    </asp:ListView>

    2.后台代码:

    protected void lvwSubsidizeList_ItemEditing(object sender, ListViewEditEventArgs e)
    {
                EnterpriseSubsidizeBLL enterpriseSubsidizeBLL = new EnterpriseSubsidizeBLL();
    
                //查找ListView中ImageButton
                ImageButton ibtn = this.lvwSubsidizeList.Items[e.NewEditIndex].FindControl("ibtnEdit") as ImageButton;
                //取出CommandArgument值
                int subID = int.Parse(ibtn.CommandArgument.ToString());
                //根据ID取出数据对象
                DAL.T_EnterpriseSubsidize subsidize = enterpriseSubsidizeBLL.GetEnterprisieSubsidizeInfo(subID);
                //项目名称
                this.txtProjectName.Text = subsidize.ProjectName;
    //批复时间 this.txtApprovalDate.Text = subsidize.ApprovalDate.ToString(); }
  • 相关阅读:
    PLSQL表
    CentOS服务器下JavaEE环境搭建指南(远程桌面+JDK+Tomcat+MySQL)
    数据分析业务调研
    Apache -poi
    Python入门经典
    高性能Linux服务器构建实战:运维监控、性能调优与集群应用
    新编 中文版CorelDRAW入门与提高
    早该这样学!Photoshop比你想的简单
    跟老男孩学Linux运维:MySQL入门与提高实践
    SQL查询的艺术
  • 原文地址:https://www.cnblogs.com/qiaoyz/p/2547509.html
Copyright © 2020-2023  润新知