1

在 Web 应用程序中,我将在绑定数据时禁用按钮,是否有可能像这样显示错误?

 <asp:Button ID ="btn" runat ="server"  CommandArgument='<%# Eval("id").ToString() == "1"? visble false: Visible true %>' />
4

3 回答 3

2

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" %>' />
于 2012-04-11T05:28:57.697 回答
2

在 DataGrid RowDataBound 事件中执行此操作

于 2012-04-11T05:19:46.563 回答
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;
}
于 2012-04-11T06:09:42.197 回答