在Web应用程序中,我将在绑定数据时禁用该按钮,这样可能会出现错误吗?
<asp:Button ID ="btn" runat ="server" CommandArgument='<%# Eval("id").ToString() == "1"? visble false: Visible true %>' />
答案 0 :(得分:2)
在DataGrid RowDataBound事件
中执行此操作答案 1 :(得分:2)
要么在数据绑定事件中执行此操作,要么像这样执行...
<asp:Button ID ="btn" runat ="server" Visible='<%# Eval("id").ToString() == "1"? "false" : "true" %>' />
答案 2 :(得分:2)
试试这个:
<asp:Button ID="Button1" runat="server" Text="Button" Visible='<%#getVisibility()%>' OnClick="btn_Click" />
代码背后:
public Boolean getVisibility()
{
Boolean b = false;
//get the boolean value based on your field condition
b = Convert.ToBoolean(Eval("FieldValue").ToString() != "MatchCondition" ? "true" : "false");
return b;
}