我要在Repeater中实现根据当前行某列的值来判断当前行一个LinkButton要不要显示出来。
现在我用Repeater1_ItemDataBound 事件 <asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound" >
..
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Response.Write("测试~");
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {
Response.Write(((LinkButton)e.Item.FindControl("btncf")).Text);
}
}在事件那边设断点根本都没被执行到~
为什么不会被执行?页面没打印文本出来。(Repeater数据绑定没有问题)
Repeater1_ItemDataBound 事件为什么不会被调用?还是我方法用错了。。请各位帮帮忙~
我以前好像这么做是可以的,不知道为什么现在不行了~
现在我用Repeater1_ItemDataBound 事件 <asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound" >
..
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Response.Write("测试~");
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {
Response.Write(((LinkButton)e.Item.FindControl("btncf")).Text);
}
}在事件那边设断点根本都没被执行到~
为什么不会被执行?页面没打印文本出来。(Repeater数据绑定没有问题)
Repeater1_ItemDataBound 事件为什么不会被调用?还是我方法用错了。。请各位帮帮忙~
我以前好像这么做是可以的,不知道为什么现在不行了~
解决方案 »
- MVC 虚拟主机发布找不到路径
- 怎么样获取grideview 模板列中的textbox的值
- sql语句解释
- 关于Ajax返回多个值
- checkboxlist控件问题!
- windows方式下如何查找iis的虚拟路径,求助!!!
- (简单)Asp.Net 读取本地文件,本地文件权限设置
- 跪求,急需!!!!!!
- 给初手的东东--ASP.NET数据库的连接(SQL,ACCESS,XML)
- 我想学习asp.net,但是以前从来没接触过,哪位大哥介绍几本好的入门书籍??/
- asp.net 发布时,提示同一依赖程序集的不同版本之间出现冲突?求解决之道。
- Set oIE=CreateObject("InternetExplorer.Application")在asp.net中怎么写?
<%#Show(Eval("??"))%> protected string Show(object strInput)
{
if(strInput.ToString()=="??")
{...}
else
{..}
}
按钮怎么获取?比如每行都有一个
<asp:LinkButton runat="Server" CommandName='<%#((BeanBusiness)Container.DataItem).ID %>' Enabled="false" OnCommand="btn_cf" ID="btncf">重发</asp:LinkButton>
怎么根据某个列隐藏这个按钮
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="XXX" Visible='<%# Eval("YourField").ToString() == "YourText" ? true : false %>'>XXX</asp:LinkButton>
</ItemTemplate>
</asp:repeater>
<asp:LinkButton ID="lbtn" runat="server" Enabled='<%#Eval("fieldName").ToString()=="true"?true:false %>'></asp:LinkButton>类似这样
<asp:LinkButton ID="lbtn" runat="server" Visible='<%#Eval("fieldName").ToString()=="true"?true:false %>'></asp:LinkButton>
<%#Show(Eval("??"))%>protected string Show(object strInput)
{
if(strInput.ToString()=="??")
{...}
else
{..}
} 如果有三种以上的情况,<asp:LinkButton ID="lbtn" runat="server" Visible='<%#Eval("fieldName").ToString()=="true"?true:false %>'></asp:LinkButton>
就显得有心没有力。