[RESOLVED]Set visible to linkbutton in gridview

I use 

         <asp:LinkButton ID="Button2" runat="server" CommandName="select" Text="select" CommandArgument='<%#Eval("picid")%>' Visible ='<%# IIf(Eval("main1") = "1", False, True)%>' />

in  gridview, but error:

Operator ‘=’ is not defined for type ‘DBNull’ and string "1".

how i do? thanks for help.

this error for when that no data, for check the no data , how i do?

Visible =’<% # IIf(Convert.ToString(Eval ("main1")) = "1", False, True) %>’
To check no data use Visible =’<% # IIf(isdbnull(Eval ("main1")) , False, True) %>’ if you still want to check the value, replace the True value with your iif(….)

Leave a Reply