在 Web 应用程序中,我将在绑定数据时禁用按钮,是否有可能像这样显示错误?
<asp:Button ID ="btn" runat ="server" CommandArgument='<%# Eval("id").ToString() == "1"? visble false: Visible true %>' />
在 Web 应用程序中,我将在绑定数据时禁用按钮,是否有可能像这样显示错误?
<asp:Button ID ="btn" runat ="server" CommandArgument='<%# Eval("id").ToString() == "1"? visble false: Visible true %>' />
Either do that in the data bound event or do it like this...
<asp:Button ID ="btn" runat ="server" Visible='<%# Eval("id").ToString() == "1"? "false" : "true" %>' />
在 DataGrid RowDataBound 事件中执行此操作
尝试这个:
<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;
}