<td scope="col" style='display:<%#Eval("RETURNSTATUS")=='0'? "none" : "inline"%>'>
<asp:Button ID="Button1" runat="server" Text="İade Et" />
</td>
我写了这段代码但不起作用。你能帮忙吗?
感谢您的回复,但它不起作用。我解决了这样的问题。我创建隐藏字段并通过#eval 设置值
<td scope="col" >
<asp:Button ID="btnReturn" runat="server" CommandArgument='<%#Eval("InventoryId")%>' Text="İade Et" OnClientClick="return confirmReturnInventory()" />
<asp:HiddenField ID="hdnStatus" runat="server" Value='<%# Eval("Status") %>' />
</td>
在c#后面,我写了repeater的方法preRender event
protected void rptInventoryList_PreRender(object sender, EventArgs e)
{
foreach (RepeaterItem ri in rptInventoryList.Items)
{
HiddenField hdnStatus = (HiddenField)ri.FindControl("hdnStatus");
Button btnReturn = (Button)ri.FindControl("btnReturn");
btnReturn.Visible = hdnStatus.Value == "0";
}
}
你能试试这个代码吗?
<td scope="col" style='<%#Eval("RETURNSTATUS")=="0"? "display:none" : "display:inline"%>'>
<asp:Button ID="Button1" runat="server" Text="İade Et" />
</td>