Repeater 绑定和控制“编辑”按钮的显示与隐藏? 小弟菜鸟跪求大神。。。。
asp.net代码:<asp:RepeaterID="Repeater1"runat="server"onitemcommand="Repeater1_ItemComma...
asp.net 代码:
<asp:Repeater ID="Repeater1" runat="server" onitemcommand="Repeater1_ItemCommand" onitemdatabound="Repeater1_ItemDataBound" >
<ItemTemplate>
<div style=" border:1px solid gray; padding:10px; margin:5px; ">
<asp:Label ID="Label1" runat="server" Visible="false" ><%#Eval("ContentID")%></asp:Label>
<asp:Label ID="Label2" runat="server"> <%#Eval("Content")%></asp:Label>
<div style=" width:auto; height:20px; text-align:right;">
发布人:
<asp:Label ID="Label3" runat="server" Text="123" ForeColor="Green"> <%#Eval("Issuer")%></asp:Label>
时间:
<asp:Label ID="Label4" runat="server" ForeColor="Green" > <%#Eval("Time")%></asp:Label>
<asp:LinkButton ID="lbtnEdit" runat="server" >编辑</asp:LinkButton>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
C#:
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
if (Session["Name"].ToString() != ((Label)e.Item.FindControl("Label3")).Text)
{
((LinkButton)e.Item.FindControl("lbtnEdit")).Visible = false;
}
}
}
想要的功能很简单,就是当数据绑定的时候 获取 发布人 然后根据 系统登录用户的名字 判断 “编辑”按钮 是否隐藏。 展开
<asp:Repeater ID="Repeater1" runat="server" onitemcommand="Repeater1_ItemCommand" onitemdatabound="Repeater1_ItemDataBound" >
<ItemTemplate>
<div style=" border:1px solid gray; padding:10px; margin:5px; ">
<asp:Label ID="Label1" runat="server" Visible="false" ><%#Eval("ContentID")%></asp:Label>
<asp:Label ID="Label2" runat="server"> <%#Eval("Content")%></asp:Label>
<div style=" width:auto; height:20px; text-align:right;">
发布人:
<asp:Label ID="Label3" runat="server" Text="123" ForeColor="Green"> <%#Eval("Issuer")%></asp:Label>
时间:
<asp:Label ID="Label4" runat="server" ForeColor="Green" > <%#Eval("Time")%></asp:Label>
<asp:LinkButton ID="lbtnEdit" runat="server" >编辑</asp:LinkButton>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
C#:
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
if (Session["Name"].ToString() != ((Label)e.Item.FindControl("Label3")).Text)
{
((LinkButton)e.Item.FindControl("lbtnEdit")).Visible = false;
}
}
}
想要的功能很简单,就是当数据绑定的时候 获取 发布人 然后根据 系统登录用户的名字 判断 “编辑”按钮 是否隐藏。 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
展开全部
asp.net 代码:
<asp:Repeater ID="Repeater1" runat="server" onitemcommand="Repeater1_ItemCommand" onitemdatabound="Repeater1_ItemDataBound" >
<ItemTemplate>
<div style=" border:1px solid gray; padding:10px; margin:5px; ">
<asp:Label ID="Label1" runat="server" Visible="false" ><%#Eval("ContentID")%></asp:Label>
<asp:Label ID="Label2" runat="server"> <%#Eval("Content")%></asp:Label>
<div style=" width:auto; height:20px; text-align:right;">
发布人:
<asp:Label ID="Label3" runat="server" Text="<%#Eval("Issuer")%>" ForeColor="Green"> </asp:Label>
时间:
<asp:Label ID="Label4" runat="server" ForeColor="Green" > <%#Eval("Time")%></asp:Label>
<asp:LinkButton ID="lbtnEdit" runat="server" >编辑</asp:LinkButton>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
C#:
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
if (Session["Name"].ToString() != ((Label)e.Item.FindControl("Label3")).Text)
{
((LinkButton)e.Item.FindControl("lbtnEdit")).Visible = false;
}
}
}
改了一处:
发布人:
<asp:Label ID="Label3" runat="server" Text="<%#Eval("Issuer")%>" ForeColor="Green"> </asp:Label>
<asp:Repeater ID="Repeater1" runat="server" onitemcommand="Repeater1_ItemCommand" onitemdatabound="Repeater1_ItemDataBound" >
<ItemTemplate>
<div style=" border:1px solid gray; padding:10px; margin:5px; ">
<asp:Label ID="Label1" runat="server" Visible="false" ><%#Eval("ContentID")%></asp:Label>
<asp:Label ID="Label2" runat="server"> <%#Eval("Content")%></asp:Label>
<div style=" width:auto; height:20px; text-align:right;">
发布人:
<asp:Label ID="Label3" runat="server" Text="<%#Eval("Issuer")%>" ForeColor="Green"> </asp:Label>
时间:
<asp:Label ID="Label4" runat="server" ForeColor="Green" > <%#Eval("Time")%></asp:Label>
<asp:LinkButton ID="lbtnEdit" runat="server" >编辑</asp:LinkButton>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
C#:
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
if (Session["Name"].ToString() != ((Label)e.Item.FindControl("Label3")).Text)
{
((LinkButton)e.Item.FindControl("lbtnEdit")).Visible = false;
}
}
}
改了一处:
发布人:
<asp:Label ID="Label3" runat="server" Text="<%#Eval("Issuer")%>" ForeColor="Green"> </asp:Label>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询