zoukankan      html  css  js  c++  java
  • 禁用绑定在Repeater的控件

    实例一:

    前台:

    <asp:Repeater ID="rp_bf" runat="server" onitemdatabound="rp_bf_ItemDataBound">
    <ItemTemplate>
    <tr>
    <td><input id="cbo_select" type="checkbox" value='<%# Eval("ID") %>' runat="server" /></td>
    <td style=" text-align:center">
    <a onclick="details('骨灰去向','/FP/Direction_Detail.aspx?','<%# Eval("ID") %>',600,360)" style="color:Red;">

    <%# new AS_Services.BLL.FP_BASE().GetModel(Eval("BASE_ID").ToString()).BASE_NAME%>
    </a>
    </td>
    </tr>
    </ItemTemplate>
    </asp:Repeater>

    后台:

    protected void rp_bf_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    string str_if_end = DataBinder.Eval(e.Item.DataItem, "if_end").ToString();//if_end绑定在Repeater
    if (str_if_end == "1") //drv.Row.ItemArray[0]就是你要取的数据源中的第0列了,你的Uname在第几列就自己写了。。。
    {
    HtmlInputCheckBox cb = e.Item.FindControl("cbo_select") as HtmlInputCheckBox;
    cb.Disabled = true;
    }
    }
    }

    实例二:

    GridView代码:

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" class="tableStyle"
    DataKeyNames="MEMBER_ID" border="0" Style=" 100%" OnRowDataBound="GridView1_RowDataBound">
    <Columns>
    <asp:TemplateField HeaderText="性别">
    <ItemTemplate>
    <%# Eval("SEX_ID").ToString().Length == 0 ? "" : Eval("SEX_ID").ToString().Trim() == "1" ? "男" : "女"%>
    </ItemTemplate>
    <ItemStyle HorizontalAlign="Center" />
    <HeaderStyle HorizontalAlign="Center" />
    </asp:TemplateField>
    <asp:TemplateField HeaderText="当前状态">
    <ItemTemplate>
    <asp:Label ID="Lb_Statue" runat="server" Text='<%# GetStatu(Eval("STATUS_ID").ToString()) %>'></asp:Label>
    </ItemTemplate>
    <ItemStyle HorizontalAlign="Center" />
    <HeaderStyle HorizontalAlign="Center" />
    </asp:TemplateField>
    <asp:TemplateField HeaderText="操作">
    <ItemTemplate>
    <a id='<%# Eval("MEMBER_ID")+"_power"%>' onclick="Open('/PU/Member_Power.aspx?ID=<%# Eval("MEMBER_ID") %>')">
    权限设置 </a>&nbsp;&nbsp;
    <asp:LinkButton ID="bm_Eidt" runat="server" Style="text-decoration: none;" PostBackUrl='<%# "../PU/Member_Edit.aspx?ID="+Eval("member_id").ToString() %>'><img src="../libs/icons/edit.gif" alt="编辑" /></asp:LinkButton>
    &nbsp;&nbsp; &nbsp;&nbsp;<a id='<%# Eval("MEMBER_ID")+"_diaodong"%>' onclick="Open('/PU/StaffTransfer.aspx?act=Staff&ID=<%# Eval("MEMBER_ID") %>')">人员调动
    </a>
    <span class="yangshi"><%# Eval("STATUS_ID") + "|" + Eval("MEMBER_ID")%></span>
    </ItemTemplate>
    <ItemStyle Width="250px" HorizontalAlign="Center" />
    <HeaderStyle HorizontalAlign="Center" />
    </asp:TemplateField>
    <asp:BoundField DataField="STATUS_ID" HeaderText="STATUS_ID">
    <ItemStyle HorizontalAlign="Center" Width="20%" CssClass="yangshi" />
    <HeaderStyle HorizontalAlign="Center" CssClass="yangshi" />
    </asp:BoundField>
    </Columns>
    <EmptyDataTemplate>
    暂无记录!</EmptyDataTemplate>
    </asp:GridView>

     JS代码:

    var spn=$("span");
    spn.each(function(){

    if($(this).text().split('|')[0]=="4"){
    $('#'+$(this).text().split('|')[1]+"_diaodong").removeAttr("onclick");
    $('#'+$(this).text().split('|')[1]+"_diaodong").css("color","gray");
    $('#'+$(this).text().split('|')[1]+"_power").removeAttr("onclick");
    $('#'+$(this).text().split('|')[1]+"_power").css("color","gray");
    }
    })

  • 相关阅读:
    Linux系统下ping命令报错 name or service not know
    利用Kettle进行SQLServer与Oracle之间的数据迁移实践
    STS中配置MyBatis代码生成器
    GeoServer中配置GeoWebCache切片缓存目录
    Win10下安装msi程序包时报2503、2502错误问题及其解决办法
    常用办公软件推荐
    Excel中使用VBA进行度分秒与十进制度的转换
    ArcGIS下图层范围不正确的两种处理方式
    更改GeoServer的端口号
    Tomcat跨域访问配置
  • 原文地址:https://www.cnblogs.com/hjianguo/p/5520479.html
Copyright © 2011-2022 走看看