首页 > Web开发 > 详细

asp:Repeater 添加button 事件

时间:2018-07-09 17:47:25      阅读:159      评论:0      收藏:0      [点我收藏+]
 <asp:Repeater runat="server" ID="repnewlsit"  OnItemCommand="itemCommand"   OnItemDataBound="repnewlsit_ItemDataBound">

        <ItemTemplate>

 <asp:LinkButton ID="btnDisable" runat="server"  CssClass='btn btn-sm btn-icon btn-danger' title="删除" 

                       CommandName="btnDisable"     CommandArgument='<%# Eval("newsid")%>' OnClientClick="return confirm('删除的案例无法恢复,确定删除吗?');"

                       ><i class="glyphicon glyphicon-trash"></i></asp:LinkButton>

</ItemTemplate>

    </asp:Repeater>



cs:

 protected void itemCommand(object source, RepeaterCommandEventArgs e)

    {

        if (e.CommandName == "btnDisable" )

        {

            int ID = int.Parse(e.CommandArgument.ToString());

          

        }

    }


//限制按钮显示

protected void repnewlsit_ItemDataBound(object sender, RepeaterItemEventArgs e)

    {

        System.Data.DataRowView dr = (System.Data.DataRowView)e.Item.DataItem;


        LinkButton btnDisable = (LinkButton)e.Item.FindControl("btnDisable");

        LinkButton btnNoDisable = (LinkButton)e.Item.FindControl("btnNoDisable");

        if (dr["lzf"].ToString().Trim() == "1")

        { btnDisable.Visible = true;

        btnNoDisable.Visible = false;

        }

        else

        {

            btnDisable.Visible = false;

                btnNoDisable.Visible = true;

        }

    }



asp:Repeater 添加button 事件

原文:http://blog.51cto.com/zhaoyingyatou/2139377

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!