1

I have below link button and I need to show it only if grid has records.

<asp:LinkButton ID="linkButton1" runat="server" ToolTip="Delete file" Visible='<%# (Convert.ToInt32(Eval("gridViewFileInformation.Rows.Count"))>0) %>' >Delete</asp:LinkButton>

But it shows always.

user966398
  • 59
  • 3
  • 12

1 Answers1

0

In your code behind file after databind of "gridViewFileInformation" you can set the Visible property of linkButton1. Similar question

Something like:

ASPX File:

<asp:GridView
    runat="server"
    ID="gridViewFileInformation"
    OnDataBound="gridViewFileInformation_DataBound">
</asp:GridView>

CS File:

protected void gridViewFileInformation_DataBound(object sender, EventArgs e)
{
    linkButton1.Visible = (gridViewFileInformation.Rows.Count > 0);
}
Community
  • 1
  • 1
Georgi Filipov
  • 332
  • 2
  • 18
  • Thanks, I can do it in DataBound event but why doesn't my current code work? – user966398 Nov 07 '14 at 22:10
  • I think this will answer your question [Set Visible property with server tag <%= %> in Framework 3.5](http://stackoverflow.com/questions/9595851/set-visible-property-with-server-tag-in-framework-3-5) – Georgi Filipov Nov 08 '14 at 16:06