禁用绑定在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="width: 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>
<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>
<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");
}
})
禁用绑定在Repeater的控件的更多相关文章
- Repeater——数据库控件学习
1.Repeater控件的使用:(用于重复加载一些内容,把要重复加载的代码写在ItemTemplate里面) 脱完控件后,在设计视图中配置数据源即可~ 2.ListView(数据显示,分页此控件一拖千 ...
- Repeater数据控件的两个重要事件ItemDataBound 和 ItemCommand
1 ItemDataBound:数据绑定的时候(正在进行时)发生. 2 ItemCommand :用来响应Item模板中的控件的事件. 如下代码 aspx代码: [html] view plain c ...
- Repeater + 分页控件 AspNetPager 研究
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs ...
- DataItem,gridview,repeater数据控件数据绑定
Container.DataItem几种方式. 在绑定数据时经常会用到这个句程序:<%# DataBinder.Eval(Container.DataItem,"xxxx") ...
- 在后台CS文件里面,隐藏和显示Repeater里面控件
<asp:Repeater ID="Repeater1" runat="server"><ItemTemplate><asp:Pa ...
- 关于asp.net中Repeater控件的一些应用
在Asp.net中,我是比较喜欢用Repeater这个控件,刚刚遇到的一个问题,怎么实现单击 <asp:LinkButton>,通过后台的单击事件获取同一行数据中的其他数据(对象). 1, ...
- asp.net中Repeater控件用法笔记
大家可能都对datagrid比较熟悉,但是如果在数据量大的时候,我们就得考虑使用 repeater作为我们的数据绑定控件了.Repeater控件与DataGrid (以及DataList)控件的主要区 ...
- Repeater 控件使用总结
关于Repeater控件使用的一些总结,希望能对将来有机会看到这篇日志的同事有所帮助.也是为了在自己开发有所遗忘的时候能够参考一下.前言:Repeater是一个迭代控件,什么是迭代控件呢?书本上的 ...
- {Repeater控件} Repeater控件的用法流程及实例
一.Repeater控件的用法流程及实例: 1.首先建立一个网站,新建一个网页index.aspx. 2.添加或者建立APP_Data数据文件,然后将用到的数据库文件放到APP_Data文件夹中. 3 ...
随机推荐
- python3与python2中的string.join()函数
在python2中,string 模块中有一个join()函数,用于以特定的分隔符分隔源变量中的字符串,将其作为新的元素加入到一个列表中,例如: body=string.join(( "Fr ...
- Linux之FTP服务
一.ftp服务 ftp是一个文件传输协议(File Transfer Protocal).lftp相当于一个浏览器,用来向服务器发送请求的. 进行FTP服务的相关操作的时候,要先修改 vim /et ...
- yii2.0 使用不同语言
1.建立语言目录.文件.项目根目录建立messages文件夹.存放不同语言对应的目录文件. 例如中文和英文 message 下建立两个文件夹 en.zh_CN 里面可以对应着多个翻译文件 2.在mai ...
- [置顶]
【机器学习PAI实践八】用机器学习算法评估学生考试成绩
(本文数据为实验用例) 一.背景 母亲是老师反而会对孩子的学习成绩造成不利影响?能上网的家庭,孩子通常能取得较好的成绩?影响孩子成绩的最大因素居然是母亲的学历?本文通过机器挖掘算法和中学真实的学生数据 ...
- bytes 与 str的区别以及装换
bytes 和 str 的区别: bytes 存储字节( 通常值在 range(0, 256)) str 存储unicode字符( 通常值在0~65535) bytes 与 str 的转换 编码(en ...
- C语言变量、函数的作用域及变量的存储方式
一.变量的作用域和存储方式 在C语言中每个变量都有两种基本属性:数据类型.数据的存储类别. 数据类型很多人都已熟知,例如:字符型(char).整型(int).浮点型(float)等等.存储类别是指数据 ...
- Srping框架中使用@query注解实现复杂查询
[自己项目代码] @Query("select bean from User bean where bean.org.id=?1 and bean.group.id=?2") pu ...
- Codeforces 828C String Reconstruction【并查集巧妙运用】
LINK 题目大意 给你n个串和在原串中的出现位置,问原串 思路 直接跑肯定是GG 考虑怎么优化 因为保证有解,所以考虑过的点我们就不再考虑 用并查集维护当前每个点之后最早的没有被更新过的点 然后就做 ...
- 《DSP using MATLAB》示例Example 8.15
- iPhone4s 9.2.1安装cydia(越狱)
依据网上资料而来 主要就是上图视频中的6步骤选项,不要选错. 1.prepare for jailbreak 2.选择Accept 3. proceed with jailbreak 4.begin ...