简体   繁体   English

在转发器中比较从数据库提取的数据值和标签数据的值不起作用asp.net C#

[英]comparing the value of data extracated from database and label data in repeater does not work asp.net c#

i want to make the edit button visible for only those users who has the same user id as the data extracted from database. 我只想使编辑按钮仅对那些具有与从数据库提取的数据相同的用户ID的用户可见。 for this I'm using repeater and I'v extracted data using repeater but when i compare the user log in value and data from database inside repeater,i don't get the value inside button.can anyone help please. 为此,我正在使用转发器,并且使用转发器提取了数据,但是当我比较用户登录值和转发器内部数据库中的数据时,我没有在按钮内部获取值。任何人都可以帮忙。 here's my code; 这是我的代码;

<asp:LinkButton ID="lbtnDelete" runat="server" CommandName="delete" 
  CommandArgument='<%# DataBinder.Eval(Container.DataItem, "id") %>' 
  OnClick="lbtnDelete_Click" Visible='<%# lLoggedUser.Text == DataBinder.Eval(Container.DataItem, "user_id") %>'>Edit</asp:LinkButton>

here lLoggedUser is login user id and "user_id" is id of user in database. 这里lLoggedUser是登录用户ID,“ user_id”是数据库中用户的ID。 But the value of lUserLogged get null. 但是lUserLogged的值将为null。

Compare it to the data you bind to LoggedUser , not the value of LoggedUser itself. 将它与您绑定到LoggedUser的数据进行LoggedUser ,而不是与LoggedUser本身的值进行LoggedUser Like 喜欢

Visible='<%# Eval("user_id").ToString() == Session["user_id"].ToString() %>

or 要么

Visible='<%# Eval("user_id") == MyUserIDVariable %>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM