Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 要基于Gridview字段中的值启用图像按钮吗_Asp.net_C# 4.0 - Fatal编程技术网

Asp.net 要基于Gridview字段中的值启用图像按钮吗

Asp.net 要基于Gridview字段中的值启用图像按钮吗,asp.net,c#-4.0,Asp.net,C# 4.0,在Gridview中,我使用希望根据字段中的值启用的图像按钮。我的部分代码是 <asp:ImageButton ID="btn_delete" **Enabled='<%# Eval("fld_status").ToString()=="1" ? "False" : "True" %>**' runat="server" ToolTip="Delete" OnClientClick="return confirm('Important Alert : Do you del

在Gridview中,我使用希望根据字段中的值启用的图像按钮。我的部分代码是

<asp:ImageButton ID="btn_delete" **Enabled='<%# Eval("fld_status").ToString()=="1" ?    "False" : "True" %>**' runat="server" ToolTip="Delete" OnClientClick="return confirm('Important Alert : Do you delete this item ?')" CommandName="del" CommandArgument='<%#Bind("fld_id") %>' />

通过
RowDataBound
(我更喜欢):

从aspx:

<asp:ImageButton ID="btn_delete" runat="server"
    Enabled='<%# ((int)Eval("fld_status") !=1) ? true : false  %>' 
    ToolTip="Delete" OnClientClick="return confirm('Important Alert : Do you delete this item ?')" CommandName="del" CommandArgument='<%#Bind("fld_id") %>' 
/>


如果fld_status=1表示,我想为图像按钮设置Enable=“False”。您是否尝试在gridview的DataItemBounded事件中执行此操作?第二个是否有效aspx:CS0019:Operator'!='中的服务器标记格式不正确不能应用于'object'和'int'类型的操作数@codingbiz:Corrected,这就是为什么我总是使用
RowDataBound
@bharathi。您应该使用codebehind中的RowDataBound-它是干净的,但如果在aspx中工作,则很容易更改。尽管如此,显示错误的指定强制转换仍然无效。
<asp:ImageButton ID="btn_delete" runat="server"
    Enabled='<%# ((int)Eval("fld_status") !=1) ? true : false  %>' 
    ToolTip="Delete" OnClientClick="return confirm('Important Alert : Do you delete this item ?')" CommandName="del" CommandArgument='<%#Bind("fld_id") %>' 
/>